can I replace all with a macro?

J

J_J

Hi,
Can I replace (all "i" characters with "ý") and (all "g" characters with
"ð") and (all "u" characters with "ü") within all cells of all Excel sheets
in a workbook with a VB macro?
TIA
 
J

J_J

Hi Bob,
Thanks for your suggestion. Yes the below code "partly" does the job
'--------------------------------
Sub Macro1()
' Macro1 Macro
' Macro recorded 20.10.2004 by J_J
Cells.Replace What:="i", Replacement:="ý", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False
Cells.Replace What:="g", Replacement:="ð", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False
Cells.Replace What:="u", Replacement:="ü", LookAt:=xlPart, SearchOrder _
:=xlByRows, MatchCase:=False
End Sub
'--------------------------------
but I need to do it far "all" existing Sheets in the workbook all in one
go...
Thanks
J_J
 
B

Bob Phillips

J_J,

This is untested, but fingers-crossed

Sub Macro1()
Dim sh As Worksheet
For Each sh In Activeworkbook.Worksheets
ReplaceAll sh, "i","y"
ReplaceAll sh, "g", "ð"
ReplaceAll sh, "u", "ü"
Next sh
End Sub

Private Sub ReplaceAll(sh As Worksheet, pWhat As String, pBy As String)
sh.Cells.Replace What:="i", _
Replacement:="ý", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False

End Sub
 
B

Bob Phillips

oops

Private Sub ReplaceAll(sh As Worksheet, pWhat As String, pBy As String)
sh.Cells.Replace What:=pWhat, _
Replacement:=pBy, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False

End Sub
 
Top