How do I search for a word in Excel Using VBA and then Delete the entire row?

user2865838

Someone please help. I'm trying to write a VBA code that searches for a particular word "DR" in my excel worksheet column "D" and then delete the entire row. There are lots of occurrences of the particular word in the worksheet. All I want to do is to search for the these occurrences and then delete the entire rows that contains those words. My problem is that I'm not sure what loop structure to use. Below is the code I'm using.

    Columns("D:D").Select
    Cells.Find(What:="DR", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
        xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
        , SearchFormat:=False).Activate
Do Cells.Find(What:="DR", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _ xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _ , SearchFormat:=False).Activate

ActiveCell.EntireRow.Delete Loop While (Cells.Find(What:="DR"))

I'll be glad for an assistance.

CustomX

Clean and simple, does the trick! ;)

LastRow = Cells(Rows.Count, "D").End(xlUp).Row

For i = LastRow To 1 Step -1
   If Range("D" & i).Value = "DR" Then
      Range("D" & i).EntireRow.Delete
   End If
Next i

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I search for a word in Excel Using VBA and then Delete the entire row?

From Dev

If a cell ends in a certain word, how do I delete the entire row? VBA

From Dev

How do I delete a row in an excel (csv) sheet using Java?

From Dev

How do I set a column to search in using Excel VBA?

From Dev

How to Highlight entire row of a Table using Excel VBA

From Dev

How do I select the first instance of a string and delete the entire row

From Dev

Excel VBA Delete Row If Misspelled Word

From Dev

Excel: How do I reference an entire row except for a couple of cells?

From Dev

Excel VBA: Delete entire row if cell in column A is blank (Long Dataset)

From Dev

Excel VBA delete entire row if both columns B and C are blank

From Dev

Excel VBA delete entire row if both columns B and C are blank

From Dev

Using Excel VBA, how to search for a specific word and insert comments against that word in a Word document?

From Dev

VBA: Within Excel how do I save a word document as a PDF?

From Dev

How do I delete any row from all excel sheet?

From Dev

How do I hide an entire row in a gird?

From Dev

How do i truncated part of a word with a wildcard using VBA

From Dev

How do I delete a particular row of a table using jQuery?

From Dev

How do I delete rows using row numbers in R?

From Dev

vba excel how to check if cell not empty and color the entire row?

From Dev

VBA Excel : Delete excel row

From Dev

Excel VBA - How do I select multiple entire columns from defined ranges?

From Dev

Excel VBA - How do I select multiple entire columns from defined ranges?

From Dev

How do I change text in a Word Doc from Excel VBA when Word Doc is located on a server?

From Dev

How to remove the entire line of a word doc using vba

From Dev

How can I delete entire row in my SQL datagridview?

From Dev

VBA/Macro to delete entire row with "only formula"

From Dev

How do I hide entire row if a certain cell in that row is empty?

From Dev

How to delete a row that contains a certain code in the first column using excel VBA?

From Dev

How do I reference tables in Excel using VBA?

Related Related

  1. 1

    How do I search for a word in Excel Using VBA and then Delete the entire row?

  2. 2

    If a cell ends in a certain word, how do I delete the entire row? VBA

  3. 3

    How do I delete a row in an excel (csv) sheet using Java?

  4. 4

    How do I set a column to search in using Excel VBA?

  5. 5

    How to Highlight entire row of a Table using Excel VBA

  6. 6

    How do I select the first instance of a string and delete the entire row

  7. 7

    Excel VBA Delete Row If Misspelled Word

  8. 8

    Excel: How do I reference an entire row except for a couple of cells?

  9. 9

    Excel VBA: Delete entire row if cell in column A is blank (Long Dataset)

  10. 10

    Excel VBA delete entire row if both columns B and C are blank

  11. 11

    Excel VBA delete entire row if both columns B and C are blank

  12. 12

    Using Excel VBA, how to search for a specific word and insert comments against that word in a Word document?

  13. 13

    VBA: Within Excel how do I save a word document as a PDF?

  14. 14

    How do I delete any row from all excel sheet?

  15. 15

    How do I hide an entire row in a gird?

  16. 16

    How do i truncated part of a word with a wildcard using VBA

  17. 17

    How do I delete a particular row of a table using jQuery?

  18. 18

    How do I delete rows using row numbers in R?

  19. 19

    vba excel how to check if cell not empty and color the entire row?

  20. 20

    VBA Excel : Delete excel row

  21. 21

    Excel VBA - How do I select multiple entire columns from defined ranges?

  22. 22

    Excel VBA - How do I select multiple entire columns from defined ranges?

  23. 23

    How do I change text in a Word Doc from Excel VBA when Word Doc is located on a server?

  24. 24

    How to remove the entire line of a word doc using vba

  25. 25

    How can I delete entire row in my SQL datagridview?

  26. 26

    VBA/Macro to delete entire row with "only formula"

  27. 27

    How do I hide entire row if a certain cell in that row is empty?

  28. 28

    How to delete a row that contains a certain code in the first column using excel VBA?

  29. 29

    How do I reference tables in Excel using VBA?

HotTag

Archive