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... |
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... |
All times are GMT +1. The time now is 06:37 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com