ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Replace characters with symbols (https://www.excelbanter.com/excel-programming/376114-replace-characters-symbols.html)

Michael

Replace characters with symbols
 
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.

Lori

Replace characters with symbols
 
Choose EditReplace: Find: ~? and Replace: a.
(Copy the alpha symbol from the windows character map or using the
Insert Symbol)


Michael wrote:

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.



Gary''s Student

Replace characters with symbols
 
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 (?
--
Gary''s Student


"Michael" wrote:

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.



All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com