Hi Tom
I was playing with union today and like to ask you this
This is working fast and great for the whole column A
Sub test2()
Dim cell As Range, Rng As Range
For Each cell In Range("A:A")
If cell.Value = 0 Or cell.Text = "ron" Then
If Rng Is Nothing Then
Set Rng = cell
Else
Set Rng = Union(Rng, cell)
End If
End If
Next
If Not Rng Is Nothing Then
Rng.EntireRow.Delete
End If
End Sub
But if I change it to this
If cell.Value = 0 Or cell.Text = "#REF!" Then
I get an error 13
Can you tell me why Tom
--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl
"Tom Ogilvy" wrote in message ...
Sub DeleteRows()
Dim r As Long
With Selection
For r = .Cells.Count To 1 Step -1
With .Cells(r, 1)
If .Value = 0 Or .Text = "#REF!" Then .EntireRow.Delete
End With
Next
End With
End Sub
will check for #REF specifically
Demo'd from the immediate window:
? activeCell.Text
#REF!
? activeCell.Text = "#REF!"
True
--
Regards,
Tom Ogilvy
JMay wrote in message news:Kcgbb.4441$AH4.1113@lakeread06...
After selecting a range, say D5:D39
where d20 might have = d25 and d25 is blank
the folowing code is stopping <<HERE-belowon d20 - haven't I provided
for
this?
TIA,
Sub DeleteRows()
Dim r As Long
With Selection
For r = .Cells.Count To 1 Step -1
With .Cells(r, 1)
HERE If .Value = 0 Or .Value = "#REF!" Then .EntireRow.Delete
End With
Next
End With
End Sub