#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 150
Default Coding Help

I'm wanting to find rows in a spreadsheet that contains the words "Use Start"
and if not found, delete the rows that do not contain the text. Here's what
I have but it doesn't work. Any help you can provide would be greatly
appreciated.

Sub cleanup2()
Dim rng As Range
Set rng = Range("A:A").Find(What:="Use Start", After:=ActiveCell,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If rng Is Nothing Then
Do
Row.Delete

Loop While rng Is Nothing
End If

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Coding Help

Key is to work from the bottom up. Either revise your formula using
findPREVIOUS within FINDNEXT or this.

Sub delallbut()
For i = Cells(Rows.Count, "a").End(xlUp).Row To 2 Step -1
If UCase(Cells(i, "a")) < "USE START" Then Rows(i).Delete
Next i
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Stan" wrote in message
...
I'm wanting to find rows in a spreadsheet that contains the words "Use
Start"
and if not found, delete the rows that do not contain the text. Here's
what
I have but it doesn't work. Any help you can provide would be greatly
appreciated.

Sub cleanup2()
Dim rng As Range
Set rng = Range("A:A").Find(What:="Use Start", After:=ActiveCell,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If rng Is Nothing Then
Do
Row.Delete

Loop While rng Is Nothing
End If

End Sub


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
sum by coding without 0 kaja New Users to Excel 2 March 1st 08 03:52 PM
Can anyone help me with coding this? John D Excel Programming 1 May 18th 07 11:36 AM
VB coding ndn14 Excel Programming 1 May 3rd 07 01:00 AM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Implant macro coding into ASP coding Sam yong Excel Programming 5 September 15th 05 10:37 AM


All times are GMT +1. The time now is 01:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"