Replace characters with symbols

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to write a macro which loops through all cells in a worksheet
and if it finds the characters (? replaces them with, for example the symbol
Alpha, but does not modify the rest of the text in the cell.
I woul be grateful if someone could tell me how to do this.
 
Choose Edit>Replace: Find: ~? and Replace: a.
(Copy the alpha symbol from the windows character map or using the
Insert > Symbol)
 
Lori's response is best, but if you need to do this in VBA, then:

Sub demo()
Dim r As Range
For Each r In ActiveSheet.UsedRange
r.Value = WorksheetFunction.Substitute(r.Value, "?", ChrW(945))
r.Value = WorksheetFunction.Substitute(r.Value, "(", ChrW(945))
Next
End Sub

to replace each of your two characters separately or

Sub demo()
Dim r As Range
For Each r In ActiveSheet.UsedRange
r.Value = WorksheetFunction.Substitute(r.Value, "(?", ChrW(945))
Next
End Sub

to replace the string (?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top