View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Delete non-selected rows

Sub Tester1()
shtbtm = Cells(65536, "a").End(xlUp).Row
For a = shtbtm To 2 Step -1
If Intersect(Rows(a), Selection) Is Nothing Then
Rows(a).Delete
End If
Next a

End Sub

--
Regards,
Tom Ogilvy


"SparePersn" wrote in message
...
Maybe I'm just being thick-headed here. Seems this should be so easy.

Excel
2002. I want to delete all the rows that are not selected by the user. I
tried this code to no avail:

ShtBtm=cells(65536,"a").end(xlup).row
for a=shtbtm to 2 step-1
if not rows(a).selected then rows(a).delete
next a

That's what I want. Excel doesn't like rows(a).selected. Help!
Thanks!