phrankndonna
12-04-2011, 11:25 AM
Hi,
I've got a routine whereby data is copied from Excel into a table in MS Word. Multiple rows are copied/pasted at one time. When the data gets opied, the text that's in the first column is oriented left in each cell. I need to then indent each of these cells two tab stops. After I select the block of cells that I need indented, I run the code below, and it does run through one time for the first cell. The code I've got below runs, and the Selection.Cells.Count code 'sees' the number of cells that are selected, and it does indent the first cell two tab stops, but then the code ends; it does not loop through each subsequent cell. How can I get it to continue the loop and indent all the selected cells? Thanks for any help/advice.
Sub IndentTextInCell()
Dim p As Paragraph
If Selection.Cells.Count > 0 Then
For Each p In Selection.Cells(1).Range.Paragraphs
p.Indent
p.Indent
Next p
End If
End Sub
Frank
I've got a routine whereby data is copied from Excel into a table in MS Word. Multiple rows are copied/pasted at one time. When the data gets opied, the text that's in the first column is oriented left in each cell. I need to then indent each of these cells two tab stops. After I select the block of cells that I need indented, I run the code below, and it does run through one time for the first cell. The code I've got below runs, and the Selection.Cells.Count code 'sees' the number of cells that are selected, and it does indent the first cell two tab stops, but then the code ends; it does not loop through each subsequent cell. How can I get it to continue the loop and indent all the selected cells? Thanks for any help/advice.
Sub IndentTextInCell()
Dim p As Paragraph
If Selection.Cells.Count > 0 Then
For Each p In Selection.Cells(1).Range.Paragraphs
p.Indent
p.Indent
Next p
End If
End Sub
Frank