View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
ryguy7272 ryguy7272 is offline
external usenet poster
 
Posts: 2,836
Default delete rows that don't contain text

I think this will do what you want:
Sub Delete_with_Autofilter()
Dim DeleteValue As String
Dim rng As Range

DeleteValue = "*Total*"
With ActiveSheet
.Range("A1:A100").AutoFilter Field:=1, Criteria1:=DeleteValue
With ActiveSheet.AutoFilter.Range
On Error Resume Next
Set rng = .Offset(1, 0).Resize(.Rows.Count - 1, 1) _
.SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireRow.Delete

End With
.AutoFilterMode = False
End With
End Sub

Notice: the range is Column A, specifically A1:A100.
Modify this to suit your needs.

Regards,
Ryan--


--
RyGuy


"Ron de Bruin" wrote:

See
http://www.rondebruin.nl/delete.htm

Try the AutoFilter example
http://www.rondebruin.nl/delete.htm#AutoFilter

Read the comments in the code

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Natdan" wrote in message ...
I have used subtotal on my data and have copied and paste special'd my data
to another sheet, I know want to delete all the rows that dont have the word
"*Total*" in them. I am fairly new to vba and would appreciate any help
anyone can give me.