Can I increment list via wildcard search/replace?

E

Ed

If my doc has a list of items like:
(a)
(b)
(c)
etc (not autogenerated), can I increment or decrement this list with a
wildcard search or replace? In other words, is there any way to search for
(a-z) and replace with \1+2 (replacing b with d) or \1-1 (replacing b with
a)? Or would it need to be done via macro?

Ed
 
G

Graham Mayor

It should be simpler to apply autonumbering and then use the wildcard
replace to remove the lettered items .

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

Ed

I apologize for my ignorance, Graham, but you have absolutely lost me. I
have rarely used the autonumbering, and I can't have an autonumbered section
in my finished document, so I am not understanding what I would look for and
replace and how to make that happen.

Ed
 
G

Graham Mayor

Why can't you have an autonumbered section?
If that isn't possible you will have to come up with another plan - such as
a macro.

eg

Sub ReplaceList()
Dim vFindText As Variant
Dim vReplText As Variant
Dim i As Long

vFindText = Array("(a)", "(b)", "(c)", "etc")
vReplText = Array("(1)", "(2)", "(3)", "etc")
With Selection.Find
.Forward = True
.Wrap = wdFindContinue
.MatchWholeWord = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Format = True
.MatchCase = True

For i = LBound(vFindText) To UBound(vFindText)
.Text = vFindText(i)
.Replacement.Text = vReplText(i)
.Execute replace:=wdReplaceAll
Next i
End With
End Sub

(see http://www.gmayor.com/installing_macro.htm )
Add in the rest of the letter/number sequences in the two arrays. Unless you
have a lot of lists it would be quicker just to edit the document manually
than create the macro


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
E

Ed

Why can't you have an autonumbered section?
I can create an autonumbered section during the drafting of the report, but
when it goes out from me it must be "plain text". The report reviewers,
though, will often want things adjusted, paragraphs inserted or deleted,
etc. I've had lists spanning pages, running from (a) to (z), starting over
with (aa), and finally ending with (ddd)! Most, though, are five to 15
items.

We alternate numbers and letters, so indents are numbered as:
2.1.3
a.
(1)
(2)
(a)
(b)
b.
etc.

If they want two paragraphs inserted before a., then I have to go through
the entire list and increment everything at that indent level up two. I
just didn't know if there was any way to use a wildcard or pattern match to
pull out the letter identifier and add or subtract the required number.

Just had a thought - perhaps a Find, then isolate the identifier. If it's a
number, increment up or down and replace the string using the new number.
If it's a letter, use Asc() to return the character code and increment
_that_ number, then use Chr() with the new number in the replacement string.
Does this sound like it might work?

Ed
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top