Hello All - I have an excel file with multiple tabs. Rows that need to be deleted have an "X" in column E. The "X" can appear in multiple locations. I would like to deleted those rows and keep the other rows in order across all tabs.
I would like to have a macro to take care of this for me.
Thank you in advance for the help !!!
Ivan
Hello Ivanur55,
This macro will clear the entire row that has an "X" in column E. I cleared the row rather than deleting it because you stated you wanted "keep the other rows in order across all tabs".
Sub DeleteRows() Dim Data As Variant Dim LastRow As Long Dim R As Long Dim Wks As Worksheet For Each Wks In Worksheets LastRow = Wks.Cells(Rows.Count, "E").End(xlUp) Data = Wks.Range("E1:E" & LastRow).Value For R = UBound(Data) To 1 Step -1 If Data(R, 1) = "X" Then Wks.Cells(R, "E").EntireRow.ClearContents Next R Next Wks End Sub
If you want to delete the row (this will shift all the rows below the deleted row up) then change the "If" statement in the macro to this...
If Data(R, 1) = "X" Then Wks.Cells(R, "E").EntireRow.Delete
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks