PDA

View Full Version : Excel Find/Replace VBA



dave
11-15-2007, 08:11 AM
Dim rw As Integer, col As Integer
For rw = START ROW To START ROW 'replace START ROW with the number of the row you want to start with
For col = YOUR COLUMN To YOUR COLUMN 'replace YOUR COLUMN with the number of the column you want to start with. You can do multiple columns.
Cells(rw, col).Select
Cells.Replace What:="REPLACEMENT TEXT HERE", Replacement:="REPLACE WITH WHAT", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next col
Next rw
Range("a1").Select

dave
02-05-2008, 02:33 PM
the above one works but I am having problems with the commas. here is the fix



Public Function removeCommas()
Dim d As Long, a As Long

d = Range("A" & Rows.Count).End(xlUp).Row
For a = 1 To d

With Cells(a, 13)
.Value = Replace(Cells(a, 13), ",", Chr(10))
.WrapText = True
End With

End Function