J
Joanne
Hello, in the following code I am search for a string which begins with the
number "1" and then looks for three or four mor numbers plus an "'". Then it
adds the found string to an array. What I would like the code to do is get
all of the instances where the first number is "1", paste them into a certain
cell in a table, then get all the instances where the first number is "2" and
paste them into another specific cell in a table, etc. etc. I'm not sure how
to increment the "iAddMan" variable, which is the number "1" or the number
"2" etc. at the start of the string, within the loop I've currently got.
Maybe my approach is wrong.
Thanks as always for any help that you can provide.
iAddNum = 1
iCount = 0
strTxt = GetPrimes(iAddNum)
strTxt = iAddNum & "[0-9]{3,4}'"
Set Doc = ActiveDocument
Set rng = Doc.Range
Set tblTab = Doc.Tables(1)
blnNumFound = True
'Set NewElemDoc = GetIndex
Doc.Activate
With rng.Find
..ClearFormatting
..Text = strTxt
..Wrap = wdFindStop
..MatchWildcards = True
..Forward = True
Do While .Execute(Replace:=wdReplaceNone)
.Execute Replace = wdReplaceNone
Selection.SelectCell
pos = InStr(Selection, iAddNum)
If pos = 1 And Selection.Cells(1).ColumnIndex = 1 Then
ReDim Preserve strAray(iCount)
strAray(iCount) = Selection
iCount = iCount + 1
End If
rng.Collapse wdCollapseEnd
Selection.Collapse wdCollapseEnd
Loop
..ClearFormatting
..Forward = True
..Text = ""
..Wrap = wdFindContinue
End With
number "1" and then looks for three or four mor numbers plus an "'". Then it
adds the found string to an array. What I would like the code to do is get
all of the instances where the first number is "1", paste them into a certain
cell in a table, then get all the instances where the first number is "2" and
paste them into another specific cell in a table, etc. etc. I'm not sure how
to increment the "iAddMan" variable, which is the number "1" or the number
"2" etc. at the start of the string, within the loop I've currently got.
Maybe my approach is wrong.
Thanks as always for any help that you can provide.
iAddNum = 1
iCount = 0
strTxt = GetPrimes(iAddNum)
strTxt = iAddNum & "[0-9]{3,4}'"
Set Doc = ActiveDocument
Set rng = Doc.Range
Set tblTab = Doc.Tables(1)
blnNumFound = True
'Set NewElemDoc = GetIndex
Doc.Activate
With rng.Find
..ClearFormatting
..Text = strTxt
..Wrap = wdFindStop
..MatchWildcards = True
..Forward = True
Do While .Execute(Replace:=wdReplaceNone)
.Execute Replace = wdReplaceNone
Selection.SelectCell
pos = InStr(Selection, iAddNum)
If pos = 1 And Selection.Cells(1).ColumnIndex = 1 Then
ReDim Preserve strAray(iCount)
strAray(iCount) = Selection
iCount = iCount + 1
End If
rng.Collapse wdCollapseEnd
Selection.Collapse wdCollapseEnd
Loop
..ClearFormatting
..Forward = True
..Text = ""
..Wrap = wdFindContinue
End With