S
saman110 via OfficeKB.com
I have Columns A:G and many cells I want to delete entire Rows if the content
of the cell contaings certain word. So far I got this Macro, but it does not
loop and I have to run it several times to get it right. is there any way I
could run it once?
Note: the code below looks at cell A2:G2 and deletes the whole Row
Sub DeleteColumns()
Dim i As Integer
For i = 256 To 1 Step -1
If Cells(2, i).Text = "Subtotal of High" Or _
Cells(2, i).Text = "Subtotal of Extremely High" Or _
Cells(2, i).Text = "Subtotal of Average" Or _
Cells(2, i).Text = "Subtotal of Below Average" Or _
Cells(2, i).Text = "Subtotal of Above Average" Or _
Cells(2, i).Text = "Grand Total" Then
Cells(2, i).EntireRow.Delete
End If
Next i
End Sub
of the cell contaings certain word. So far I got this Macro, but it does not
loop and I have to run it several times to get it right. is there any way I
could run it once?
Note: the code below looks at cell A2:G2 and deletes the whole Row
Sub DeleteColumns()
Dim i As Integer
For i = 256 To 1 Step -1
If Cells(2, i).Text = "Subtotal of High" Or _
Cells(2, i).Text = "Subtotal of Extremely High" Or _
Cells(2, i).Text = "Subtotal of Average" Or _
Cells(2, i).Text = "Subtotal of Below Average" Or _
Cells(2, i).Text = "Subtotal of Above Average" Or _
Cells(2, i).Text = "Grand Total" Then
Cells(2, i).EntireRow.Delete
End If
Next i
End Sub