Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / January 2007

Tip: Looking for answers? Try searching our database.

Decided to put this question in a new message

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sparks - 03 Jan 2007 15:38 GMT
I have to take a ton of variables and change the names..
Luck has it that they are formatted the same

Q9BOB
Q10Carl
Q11DOB
Q12RACE
.
.
.
Q149Pre

the thing is I have to rename them all and reduce the value by 2.
Q7BOB
Q8Carl
Q9DOB
Q10RACE
.
.
.
Q147Pre

Should I be looking for Numeric or chr substrings to identify what is
the number in the variable name that I have to subtract
is there a command in the mid statement to find the first chr after a
number or how should I go about parsing out the number making sure to
get the correct amount of numerics.

I assume it will always be mid(1,  to take care of the Q but length of
the numerics.
Should I look for ascii values and find out when the next one is over
57  then I am at the end of the numeric sequence.

thank you from a very confused persion...I have all the tools but not
sure how to put it together
Doug Robbins - Word MVP - 03 Jan 2007 17:43 GMT
Use a macro containing the following code:

Dim srange As Range
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
   Do While .Execute(FindText:="Q[0-9]{1,}", MatchWildcards:=True, _
       MatchCase:=False, Wrap:=wdFindStop, Forward:=True) = True
       Set srange = Selection.Range.Duplicate
       Selection.Collapse wdCollapseEnd
       Selection.MoveRight wdCharacter, 1
       srange.Text = "Q" & (Mid(srange.Text, 2) - 2)
   Loop
End With

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I have to take a ton of variables and change the names..
> Luck has it that they are formatted the same
[quoted text clipped - 31 lines]
> thank you from a very confused persion...I have all the tools but not
> sure how to put it together
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.