Hey all, does anyone know of a way to look for "some text" in a cell in a
table, then move to the cell to the right of that cell and put "some other
text"?
I have the following - but it sometimes puts the "some other text" twice:
With ActiveDocument.Content.Find
.ClearFormatting
Do While .Execute(FindText:="some text", Forward:=True, _
Format:=True) = True
'Selection.Delete
Selection.SelectCell
Selection.MoveRight
'With .Parent
With .Parent
.StartOf Unit:=wdParagraph, Extend:=wdMove
.Move Unit:=wdCell, Count:=1
.InsertAfter "some other text"
.Move Unit:=wdCell, Count:=1
End With
Loop
End With
Also, ideally I would like to delete that "some text" first and then move to
the cell to the right and put "some other text". You can see where I have
deleted that portion of the code - because that just totally messed things up.
Thanks,
Novice
Doug Robbins - 09 Dec 2004 10:42 GMT
Try this:
Dim arange As Range, i As Long, j As Long
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="some text", Forward:=True) = True
Set arange = Selection.Range
i = arange.Information(wdEndOfRangeRowNumber)
j = arange.Information(wdEndOfRangeColumnNumber)
Selection.Tables(1).Cell(i, j + 1).Range.InsertAfter "Some other
text"
Selection.Tables(1).Cell(i, j).Range.Delete
Loop
End With
If "some text" is in the last column, it would need some modification to
insert "Some other text" in the first cell in the next row, but I am
assuming that is not the case.

Signature
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.
Hope this helps,
Doug Robbins - Word MVP
> Hey all, does anyone know of a way to look for "some text" in a cell in a
> table, then move to the cell to the right of that cell and put "some other
[quoted text clipped - 26 lines]
> Thanks,
> Novice