View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Todd Huttenstine[_2_] Todd Huttenstine[_2_] is offline
external usenet poster
 
Posts: 237
Default Deleting Rows beased on Values

It gives me the error "Object variable or with block not
set" and highlights the below part of the code yellow.

rng.EntireRow.Delete




-----Original Message-----
Again, not tested with real data:

Dim c As Range, rng As Range
For Each c In Sheet1.Range("A5:A100")
If Sheet2.Range("B3:B97").Find(c.Value) Is Nothing

Then
If rng Is Nothing Then
Set rng = c
Else
Set rng = Union(rng, c)
End If
End If
rng.EntireRow.Delete
Next

--

Vasant


"Todd Huttenstine"

wrote in message
...
I have values that are on Sheet1 in Range A5:A100. On
Sheet2 I have values that are in Range in B3:B97. I

need
a code that will look in the Range on Sheet1 and for

each
value in that range, if it does not find that value in

the
Range on sheet2, will delete the value in the range on
Sheet1 as well as the entire Row that the value is

located
on.

Thank you

Todd



.