hogg
11-13-2008, 06:40 AM
Hey!
Thanks for all the help recently but I've got another problem which I can't solve!:dunno
I need to look up a value in a table and split the table where the value occours. There are several cells with the same text. I think I'm close to a solution but I'm missing a vital line or two of code! What happens at the moment is the value is found, replaced with a table split and then the same value is founds again! I've tried replaceing the text before the table split but the document just crashes becuse it keeps replacing the same text!
heres what I've got:
Sub Lookup_replace()
Do Until ActiveDocument.Bookmarks("\Sel") = _
ActiveDocument.Bookmarks("\EndOfDoc")
Selection.Find.ClearFormatting
With Selection.Find
.Text = "R.Replace"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
Selection.Find.Replacement.Text = " "
Selection.SplitTable
Else
Exit Do
End If
Loop
End Sub
What am I missing?
Thanks for your help!
Thanks for all the help recently but I've got another problem which I can't solve!:dunno
I need to look up a value in a table and split the table where the value occours. There are several cells with the same text. I think I'm close to a solution but I'm missing a vital line or two of code! What happens at the moment is the value is found, replaced with a table split and then the same value is founds again! I've tried replaceing the text before the table split but the document just crashes becuse it keeps replacing the same text!
heres what I've got:
Sub Lookup_replace()
Do Until ActiveDocument.Bookmarks("\Sel") = _
ActiveDocument.Bookmarks("\EndOfDoc")
Selection.Find.ClearFormatting
With Selection.Find
.Text = "R.Replace"
.Replacement.Text = " "
.Forward = True
.Wrap = wdFindStop
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = True Then
Selection.Find.Replacement.Text = " "
Selection.SplitTable
Else
Exit Do
End If
Loop
End Sub
What am I missing?
Thanks for your help!