Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Looping | Excel Discussion (Misc queries) | |||
finding & looping | Excel Discussion (Misc queries) | |||
Not Looping | Excel Discussion (Misc queries) | |||
Looping | Excel Discussion (Misc queries) | |||
Looping Macro to Find and Mark | New Users to Excel |