I am trying to clean some text contained in an very large Excel spreadsheet by replacing all instances "<br />" with a single space (" "). I've tried two methods: using the normal Find/Replace All options in Excel, and using this very simple VBA macro:
Sub CleanUp()
Application.Cells.Replace What:="<br />", Replacement:=Chr(32), LookAt:=xlPart
End Sub
In both cases, I receive an error message that states: "The formula you typed contains an error. For information about fixing common formula problems, click Help. To get assistance in entering a function, click Function Wizard (Formulas tab, Function Library group). If you are not trying to enter a formula, avoid using an equal sign (=) or minus sign (-), or precede it with a single quotation mark (')."
Of course, I am NOT trying to enter a formula. However, preceding "<br />" with a single quotation mark as Excel suggests does not fix the problem.
Even though my search string doesn't contain any wildcards (as far as I know), I've tried playing around with literal characters in my macro to see if that would help. It doesn't fix the problem, but here's the code anyway:
Sub CleanUp()
Dim SearchFor As String
SearchFor = Chr$(60) & "br" & Chr$(32) & Chr$(47) & Chr$(62)
Application.Cells.Replace What:=SearchFor, Replacement:=Chr$(32), LookAt:=xlPart
End Sub
Useful facts:
- I can easily find and replace other strings in this spreadsheet using both the normal find/replace method AND the VBA macro.
- I have other similar spreadsheets in which finding and replacing "<br />" is possible.
- On my friend's computer it is possible to find and replace all instances of "<br />" using both methods.
Does anyone have ANY idea why this is happening? Does it have something to do with my Excel settings?