H
Harry-Wishes
I am trying to write a script that will find any numeric supscripts or
superscripts in any cells of the activate worksheet and replace it with
another character. I have not been able to do this successfully in Excel even
when I do this manually through Excel's find and replace. It works when I
remove the filter that restricts the search to just characters that are super
or subscripted in a cell.
I have no trouble doing this in Word as you can see from the snippit I used
below for one of my Word projects. Is their an Excel equivalent?
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9]{1,2})"
.Replacement.Text = "|\1|"
.Forward = True
.Wrap = wdFindwdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
While Selection.Find.Execute
If Selection.Font.Superscript = True Then
Selection.Find.Execute Replace:=wdReplaceOne
Selection.MoveRight Unit:=wdCharacter, count:=1
End If
With Selection.Find
.Text = "([0-9]{1,2})"
.Replacement.Text = "|\1|"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Wend
Thanks.
Harry Wishes
superscripts in any cells of the activate worksheet and replace it with
another character. I have not been able to do this successfully in Excel even
when I do this manually through Excel's find and replace. It works when I
remove the filter that restricts the search to just characters that are super
or subscripted in a cell.
I have no trouble doing this in Word as you can see from the snippit I used
below for one of my Word projects. Is their an Excel equivalent?
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "([0-9]{1,2})"
.Replacement.Text = "|\1|"
.Forward = True
.Wrap = wdFindwdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
While Selection.Find.Execute
If Selection.Font.Superscript = True Then
Selection.Find.Execute Replace:=wdReplaceOne
Selection.MoveRight Unit:=wdCharacter, count:=1
End If
With Selection.Find
.Text = "([0-9]{1,2})"
.Replacement.Text = "|\1|"
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Wend
Thanks.
Harry Wishes