I build VBA code in Word tables and am tired of selecting a cell, duplicating it, selecting those two to make 4, 8, 16 and so on and then having to delete superfluous rows at the end of the table.
hence:
Code: Select all
Sub FillDownFromCurrentCell()
''' Comments: Fill to the end of the column from the first selected cell
''' Arguments: None
''' Returns: None
Dim strCellText As String
strCellText = Selection.Cells(1).Range.Text
strCellText = Left(strCellText, Len(strCellText) - 2) ' trim cell markers/vbcrlf
While Not Selection.Cells(1).Row.IsLast
Selection.Tables(1).Rows(Selection.Cells(1).Row.Index + 1).Cells(Selection.Cells(1).Column.Index).Range.Select
Selection.Text = strCellText
Wend
End Sub