View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Vergel Adriano Vergel Adriano is offline
external usenet poster
 
Posts: 857
Default Excel macro that deletes all rows which doesn't contain the ch

Hi Luca,

The code also deleted the ones with "|" in column E but you wanted to do the
opposite <g. Try this :

Sub test()
Dim rng As Range
Dim c As Range
For Each c In Intersect(ActiveSheet.UsedRange, ActiveSheet.Range("E:E"))
If InStr(1, c.Text, "|") = 0 Then
If rng Is Nothing Then
Set rng = c
Else
Set rng = Union(rng, c)
End If
End If
Next c
If Not rng Is Nothing Then
rng.EntireRow.Delete
End If
End Sub


--
Hope that helps.

Vergel Adriano


"Luca Villa" wrote:

Adriano, it seems that you're solution only deletes the column "E".
How can I make it delete the entire row in these cases?

Norman, thanks! I'm trying it now.