I have the following code
Sub CleanCat()
Dim i As Integer
For i = 1 To 50
Columns("A").Replace What:="Cat" & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Columns("A").Replace What:="Cat " & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Columns("A").Replace What:="Category " & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Columns("A").Replace What:="Category" & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Columns("A").Replace What:="cat" & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Columns("A").Replace What:="cat " & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Columns("A").Replace What:="category " & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Columns("A").Replace What:="category" & i, Replacement:="Category" & i, LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, ReplaceFormat:=False
Next
End Sub
What I want is to loop through every cell in column A and do the replacements shown (I am looping through tweets) but this doesn't replace everything. I get stuff such as something cat 13 here left
Example tweets:
@thisaccount I nominate @thataccountfor category 12 #somehashtag
Cat 12 I nominate @thisaccount #somehashtag
Any ideas?


cat 13is not the same ascat13and you should loop backwards so that replacingcat 1doesn't replacecat 13.Columns("A").Replace What:=chr(160), Replacement:=chr(32))before entering the loop.