View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
filo666 filo666 is offline
external usenet poster
 
Posts: 265
Default Macro/Loop If Statement Help -delete the row with the specific te

try this:

a=1
while a < numberofrows
If cells(a,numcol).Interior.ColorIndex = 6 and cells(a,numcol)="AB" Then
rows(a).delete
a=a+1
else if
a=a+1
end if
wend

remember to change numcol to the number of the column were your AB's are and
numberofrows to the number of the last row used

"Bricktop" wrote:

I am trying to find all the cells in my worksheet that have "AB" in column
'I' and the AB is highlighted with an interior color = 6 .... then delete the
row .

Here is what I have so far.

FIRSTROW = 1
Do While FIRSTROW 0
FIRSTROW = Application.Match("AB", Range("i:i"), 0)
If Range("a" & FIRSTROW).Interior.ColorIndex = 6 Then
Rows(FIRSTROW & ":" & FIRSTROW).Select
Selection.Delete
End If

'this is the part that is not working. What is happening is that when their
is no match the code bombs so I tried to put an if statement in to change the
firstrow to 0 if their is no match. But the if statement is not working.

If FIRSTROW = Application.Match("AB", Range("i:i"), 0) Is Nothing Then
FIRSTROW = 0
End If
Loop