View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default for each c in range.. how set counter "minus 1"?

If you don't have any formulas that produce error values in the column:

Sub DeleteRows()
Dim r As Range, tel As String
tel = "ABC"
Columns(6).Replace _
What:=tel, _
Replacement:="=na()", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
On Error Resume Next
Set r = Columns(6).SpecialCells(xlFormulas, _
xlErrors)
On Error GoTo 0
If Not r Is Nothing Then
r.EntireRow.Delete
End If
End Sub

and less than 8190 separate areas to delete.

--
Regards,
Tom Ogilvy


"mino" wrote:

Hi.
In my code, I delete the entire row of a particolar cell 'c' (if tel = c).
However, the loop "next c" jump to next one, but the real new 'c' is in the
same row, because actual 'c' in same row is deleted.
How can set c counter minus 1?

[...]
For Each c In Range("F:F")
If tel = c Then
Rows((c.Row)).Delete
End If
End If
Next c
[...]

Thanks to all
M.