View Single Post
  #2   Report Post  
Greg Maxey
 
Posts: n/a
Default

Perplexed,

You can to this with a macro. I would use Select Case vice IFThenElse.

Sub MoveText()
Dim oTbl As Table
Dim txtString As String

Set oTbl = ActiveDocument.Tables(1)
txtString = oTbl.Cell(1, 1).Range.Text
Select Case 2
Case Len(oTbl.Cell(1, 2).Range.Text)
oTbl.Cell(1, 2).Range.Text = txtString
Case Len(oTbl.Cell(1, 3).Range.Text)
oTbl.Cell(1, 3).Range.Text = txtString
Case Len(oTbl.Cell(1, 4).Range.Text)
oTbl.Cell(1, 4).Range.Text = txtString
Case Len(oTbl.Cell(1, 5).Range.Text)
oTbl.Cell(1, 5).Range.Text = txtString
Case Len(oTbl.Cell(1, 6).Range.Text)
oTbl.Cell(1, 6).Range.Text = txtString
Case Len(oTbl.Cell(1, 7).Range.Text)
oTbl.Cell(1, 7).Range.Text = txtString
Case Else
MsgBox "All cells are in use."
End Select

End Sub


--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

Perplexed wrote:
I have a Microsoft Word table that has seven cells in the row. Some
of the cells have text in them already and some do not. I want to
move the text from the first cell to one of the empty cells. I need
to write an If statement that will test if the cell I'm moving the
text into is empty before it pastes the text in it. If the cell is
empty, then paste the text into that cell, if it's not empty, then
move to the next cell to the right and test if that cell is empty
before pasting the text. It should test for an empty cell five times
before ending the If statement. Can anyone help me to write an If
statement to accomplish this?