ASKER
ASKER
Sub ReplaceWords()
Dim lr As Long, i As Long
Dim rng As Range
Dim replWhat As String
Dim replWith As String
Dim str() As String
lr = Cells(Rows.Count, 1).End(xlUp).Row
Set rng = Range("A1:A" & lr)
replWhat = Application.InputBox("What word/string you want to replace?", "String To Be Replaced!")
If replWhat = "False" Then
MsgBox "You didn't input the string to be replaced", vbExclamation
Exit Sub
End If
str() = Split(replWhat, ",")
replWith = Application.InputBox("What is the word/string you want to replace with?", "String To Be Replaced With!")
For i = 0 To UBound(str)
If str(i) <> " " Then
rng.Replace What:=str(i), Replacement:=replWith, LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
Next i
End Sub
ASKER
Microsoft Excel topics include formulas, formatting, VBA macros and user-defined functions, and everything else related to the spreadsheet user interface, including error messages.
TRUSTED BY
Open in new window