LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Find and Replace text with formatting

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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Replace loses text properties/formatting no1jimmyman Excel Worksheet Functions 1 February 3rd 11 09:56 PM
Find and Replace with Formatting brownti via OfficeKB.com Excel Programming 3 April 17th 08 10:10 PM
Find and Replace - delete the remainder of the text in the cell after my Find [email protected] Excel Programming 4 August 4th 07 03:39 AM
Find and replace of word causes change of font formatting jwa90010 New Users to Excel 4 July 22nd 05 08:10 PM
Find and Replace formatting inside of a macro mlstjohn Excel Programming 0 November 11th 04 04:16 PM


All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"