PDA

View Full Version : How to do the loop for find text in a particular column ?



clif
02-15-2012, 10:07 PM
How to do the loop for find text in a particular column ?

Columns("W:W").Select

Selection.Find(What:="abc", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, MatchByte:=False, SearchFormat:=False).Activate

Selection.FindNext(After:=ActiveCell).Activate

Selection.Offset(0, -1).Select
ActiveCell.FormulaR1C1 = "bdc"

mancubus
02-16-2012, 01:25 AM
With Range("W1:W" & Cells(Rows.Count, "W").End(xlUp).Row)
'http://www.cpearson.com/excel/FindAll.aspx
Set LastCell = .Cells(.Cells.Count)
Set FoundCell = .Find(what:="abc", After:=LastCell)
If Not FoundCell Is Nothing Then
FirstAddr = FoundCell.Address
End If
Do Until FoundCell Is Nothing
FoundCell.Offset(0, -1) = "bdc"
Set FoundCell = .FindNext(After:=FoundCell)
If FoundCell.Address = FirstAddr Then
Exit Do
End If
Loop
End With