Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
pk pk is offline
external usenet poster
 
Posts: 27
Default Looping Find

Hello, I hope someone can help me with this.

Could someone give me some code that will loop as in the
following logic:

do
Find the next cell in column D containing "Red"
Activate the found cell
do something to the found cell
loop until no more are found

Thanks in advance...for your assistance...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Looping Find

One way:

If you're modifying the found cell so that it won't continue to be
found:

Dim found As Range
Set found = Columns(4).Find( _
What:="Red", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not found Is Nothing Then
Do
found.Value = found.Value & " Rover"
Set found = Columns(4).FindNext(After:=found)
Loop Until found Is Nothing
End If

If you're not modifying the found cell:

Dim found As Range
Dim foundAddr As String
Set found = Columns(4).Find( _
What:="Red", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not found Is Nothing Then
foundAddr = found.Address
Do
found.Offset(0, 1).Value = "Rover"
Set found = Columns(4).FindNext(After:=found)
Loop Until found.Address = foundAddr
End If

Note that I didn't activate the found cell because it's almost never
necessary.

In article ,
"pk" wrote:

Hello, I hope someone can help me with this.

Could someone give me some code that will loop as in the
following logic:

do
Find the next cell in column D containing "Red"
Activate the found cell
do something to the found cell
loop until no more are found

Thanks in advance...for your assistance...

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
Looping Maggie[_6_] Excel Discussion (Misc queries) 6 October 2nd 08 09:14 PM
finding & looping Jase Excel Discussion (Misc queries) 0 May 13th 08 08:01 PM
Not Looping Roger Excel Discussion (Misc queries) 0 February 26th 08 05:18 PM
Looping David T Excel Discussion (Misc queries) 2 August 30th 06 10:51 PM
Looping Macro to Find and Mark Big Tony New Users to Excel 8 January 26th 05 09:07 PM


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