sandramac
asked on
Remove Rows based on criteria
Hello
I have two sheets in a workbook, I need to create a macro that will search both sheets and if *Load Balance* or "White Noise* is found, then delete that entire row and move the rows below it up.
I have two sheets in a workbook, I need to create a macro that will search both sheets and if *Load Balance* or "White Noise* is found, then delete that entire row and move the rows below it up.
ASKER
The data can appear in any Column within A:L
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Another approach is this...
Assuming row1 is the header row on each sheet. If not change the row number in line 8 With ws.Rows(1)
Assuming row1 is the header row on each sheet. If not change the row number in line 8 With ws.Rows(1)
Sub DeleteRows()
Dim ws As Worksheet
Dim lr As Long
Application.ScreenUpdating = False
For Each ws In Worksheets
lr = ws.UsedRange.Rows.Count
ws.AutoFilterMode = 0
With ws.Rows(1)
For c = 1 To ws.UsedRange.Columns.Count
.AutoFilter field:=c, Criteria1:="=*white noise*", Operator:=xlOr, Criteria2:="=*load balance*"
If ws.Range("A1:A" & lr).SpecialCells(xlCellTypeVisible).Cells.Count > 1 Then
ws.Range("A2:A" & lr).SpecialCells(xlCellTypeVisible).EntireRow.Delete
End If
.AutoFilter field:=c
Next c
End With
Next ws
Application.ScreenUpdating = True
End Sub
ASKER
Thank You
sandramac..You are welcome...Always happy to help.. :-)
Saurabh...
Saurabh...
Saurabh...