#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Loop

Trying to Loop the below macro until foundcell is nothing, any ideas?

Range("A1").Select

Dim FoundCell As Range
With Worksheets("StockSheet")

Range("A1").Select

Set FoundCell = .Cells.Find(What:="BOO", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then

Else

FoundCell.EntireRow.Delete
End If

End With
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,593
Default Loop

Sub yty()
Dim FoundCell As Range
Dim rng As Range
Dim sFirst As String

Range("A1").Select

With Worksheets("StockSheet")

Set FoundCell = .Cells.Find(What:="BOO", After:=Range("A1"), _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext,
_
MatchCase:=False, SearchFormat:=False)

If Not FoundCell Is Nothing Then
sFirst = FoundCell.Address
Set rng = FoundCell

Do
Set FoundCell = .FindNext(FoundCell)
If Not FoundCell Is Nothing Then
Set rng = Union(rng, FoundCell)
End If
Loop While Not FoundCell Is Nothing And FoundCell.Address <
sFirst

End If

If Not rng Is Nothing Then rng.EntireRow.Delete

End With

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Heather O'Malley" wrote in message
. ..
Trying to Loop the below macro until foundcell is nothing, any ideas?

Range("A1").Select

Dim FoundCell As Range
With Worksheets("StockSheet")

Range("A1").Select

Set FoundCell = .Cells.Find(What:="BOO", After:=ActiveCell, _
LookIn:=xlFormulas, LookAt:=xlPart, _
SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)

If FoundCell Is Nothing Then

Else

FoundCell.EntireRow.Delete
End If

End With



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
how to put a loop in a macro? Khoshravan New Users to Excel 4 May 14th 06 01:22 PM
Loop time seems dependent on unrelated workbook - Why? Richard Excel Worksheet Functions 2 March 30th 06 11:59 PM
Loop gone crazy Dave Peterson Excel Discussion (Misc queries) 4 December 16th 05 03:38 PM
Do Loop Noemi Excel Discussion (Misc queries) 0 December 8th 05 10:43 PM
VB for excel, how do I loop through code steve hobden via OfficeKB.com Excel Discussion (Misc queries) 2 June 9th 05 01:59 PM


All times are GMT +1. The time now is 06:03 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"