Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-19-2015, 07:24 AM
AlexandarR AlexandarR is offline Find superscript numbers with a prefix of some default text Windows XP Find superscript numbers with a prefix of some default text Office 2003
Novice
Find superscript numbers with a prefix of some default text
 
Join Date: Mar 2015
Location: Chennai, Tamilnadu, India
Posts: 7
AlexandarR is on a distinguished road
Default Find superscript numbers with a prefix of some default text

Hi!
I have to find "Ref.[sup]2[/sup]", etc. i.e., default text "Ref." with superscript numbers.

I can find "Ref." and superscript numbers separately. But, I don't know, how to find them combined.



Anybody please help!

Regards
Alex
Reply With Quote
  #2  
Old 05-19-2015, 11:34 PM
Robert2 Robert2 is offline Find superscript numbers with a prefix of some default text Windows 8 Find superscript numbers with a prefix of some default text Office 2007
Competent Performer
 
Join Date: Jun 2013
Posts: 162
Robert2 will become famous soon enoughRobert2 will become famous soon enough
Default

Do it in two steps.
First, temporarily underline any “Ref.+number” string with red:
1. Find What: Ref.^#
2. Replace With: ^&
+ Format=red underline

Then, search for red underlined text that is superscripted.

This will give you all superscripted numbers associated with “Ref.”.

When you have finished dealing with the superscripted numbers, remove the temporary red underline.

HTH.
Cheers,
Robert
Reply With Quote
  #3  
Old 05-20-2015, 01:41 AM
gmayor's Avatar
gmayor gmayor is offline Find superscript numbers with a prefix of some default text Windows 7 64bit Find superscript numbers with a prefix of some default text Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

If you are looking for sequences like
Ref.[sup]2[/sup]
to replace with
Ref.2 (with the 2 superscripted)
then the following macro will do that. (http://www.gmayor.com/installing_macro.htm)
Code:
Sub ReplaceSuperscript()
Dim oRng As Range
Const strList As String = "0123456789"
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:="Ref.[sup]")
            oRng.MoveEndUntil "]"
            oRng.End = oRng.End + 1
            oRng.Text = Replace(oRng.Text, "[sup]", "")
            oRng.Text = Replace(oRng.Text, "[/sup]", "")
            oRng.MoveStartUntil strList
            oRng.Font.Superscript = True
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Exit Sub
End Sub
If however you want to find Ref. with a superscripted number following then
Code:
Sub FindSuperscript()
Dim oRng As Range
Const strList As String = "0123456789 "
    Set oRng = ActiveDocument.Range
    With oRng.Find
        Do While .Execute(FindText:="Ref.")
            oRng.MoveEndWhile strList
            'Do something with the found text e.g.
            oRng.HighlightColorIndex = wdYellow
            oRng.Collapse 0
        Loop
    End With
lbl_Exit:
    Exit Sub
End Sub
But in the latter case you will need to indicate what you want to do with the found reference.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 05-20-2015, 05:33 AM
gmaxey gmaxey is offline Find superscript numbers with a prefix of some default text Windows 7 32bit Find superscript numbers with a prefix of some default text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Your question was asked and answered yesterday in the VBA Express forum. When you cross-post please have the courtesy to indicate that fact in your post. Otherwise as evidenced here people waste their valuable time giving your assistance for free!!

Code:
Sub ScratchMacro() 
     'A basic Word macro coded by Greg Maxey
    Dim oRng As Word.Range 
    Set oRng = ActiveDocument.Range 
    With oRng.Find 
        .Text = "Ref." 
        While .Execute 
            Do While oRng.Characters.Last.Next Like "[0-9]" _ 
                And oRng.Characters.Last.Next.Font.Superscript 
                oRng.MoveEnd wdCharacter, 1 
            Loop 
            oRng.Select 'Do something with the found range.
            oRng.Collapse wdCollapseEnd 
        Wend 
    End With 
lbl_Exit: 
    Exit Sub 
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #5  
Old 05-20-2015, 06:45 AM
AlexandarR AlexandarR is offline Find superscript numbers with a prefix of some default text Windows XP Find superscript numbers with a prefix of some default text Office 2003
Novice
Find superscript numbers with a prefix of some default text
 
Join Date: Mar 2015
Location: Chennai, Tamilnadu, India
Posts: 7
AlexandarR is on a distinguished road
Default

Quote:
Originally Posted by Robert2 View Post
Do it in two steps.
First, temporarily underline any “Ref.+number” string with red:
1. Find What: Ref.^#
2. Replace With: ^&
+ Format=red underline

Then, search for red underlined text that is superscripted.

This will give you all superscripted numbers associated with “Ref.”.

When you have finished dealing with the superscripted numbers, remove the temporary red underline.

HTH.
Cheers,
Robert
Thank you for come forward to help!

Sorry! I didn't mention it before, but, I need to do this by macro. When I record macro, it didn't meet the requirement...

Regards
Alex
Reply With Quote
  #6  
Old 05-20-2015, 07:10 AM
AlexandarR AlexandarR is offline Find superscript numbers with a prefix of some default text Windows XP Find superscript numbers with a prefix of some default text Office 2003
Novice
Find superscript numbers with a prefix of some default text
 
Join Date: Mar 2015
Location: Chennai, Tamilnadu, India
Posts: 7
AlexandarR is on a distinguished road
Default

The above macro is finding both with/without superscript number along with the text "Ref."
Reply With Quote
  #7  
Old 05-20-2015, 07:46 AM
gmaxey gmaxey is offline Find superscript numbers with a prefix of some default text Windows 7 32bit Find superscript numbers with a prefix of some default text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Which above macro? There are three:

Code:
Sub ScratchMacro()
     'A basic Word macro coded by Greg Maxey
    Dim oRng As Word.Range
    Set oRng = ActiveDocument.Range
    With oRng.Find
        .Text = "Ref."
        While .Execute
            Do While oRng.Characters.Last.Next Like "[0-9]" _
                And oRng.Characters.Last.Next.Font.Superscript
                oRng.MoveEnd wdCharacter, 1
            Loop
            If Len(oRng.Text) > 4 Then
              oRng.Select 'Do something with the found range.
            End If
            oRng.Collapse wdCollapseEnd
        Wend
    End With
lbl_Exit:
    Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #8  
Old 05-20-2015, 07:57 AM
AlexandarR AlexandarR is offline Find superscript numbers with a prefix of some default text Windows XP Find superscript numbers with a prefix of some default text Office 2003
Novice
Find superscript numbers with a prefix of some default text
 
Join Date: Mar 2015
Location: Chennai, Tamilnadu, India
Posts: 7
AlexandarR is on a distinguished road
Default

Thanks a lot!!!

It works fine...!!!

Regards
Alex
Reply With Quote
Reply

Tags
find, numbers, superscript

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and replace BETWEEN numbers WordUser2015 Word 4 12-19-2014 02:09 PM
Show Page Numbers by default zamani_2012 Word 1 06-09-2014 06:09 AM
Macro to find text only footnote numbers TimFromPhx Word VBA 7 04-10-2014 07:05 PM
Find and replace page numbers in body of text tollanarama Word 3 02-13-2011 06:00 AM
Find superscript numbers with a prefix of some default text Find & Replace words with "/" prefix & suffix tollanarama Word 4 01-25-2011 02:19 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:13 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft