title: Macro to add text to a selected range in a Word Table
body: <p>I am trying to write a Macro that allows the user to select a range of cells in a Word Table to populate Column 4 with a specific text "SOLD".</p>
  
  <p><a href="https://i.stack.imgur.com/R5yiS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R5yiS.jpg" alt="Word table"></a></p>
  
  <p>Below is my VBA Macro code so far, but it only types the text in the first Column 4 (rather than the selected range of column 4's)</p>
  
  <pre><code>Dim iSelectionRowEnd As Integer
  Dim iSelectionRowStart As Integer
  Dim cl1 As Cell
  Dim cl2 As Cell
  Dim tbl As Table
  Dim rng As Range
  
  ActiveDocument.Bookmarks.Add Name:="MacroStartPosition", Range:=Selection.Range
  
  If Selection.Information(wdWithInTable) = False Then
      MsgBox "Selection is not in a table."
  Else
  
      iSelectionRowEnd = Selection.Information(wdEndOfRangeRowNumber)
      Selection.Collapse Direction:=wdCollapseStart
  
  
      iSelectionRowStart = Selection.Information(wdEndOfRangeRowNumber)
  
      Set tbl = Selection.Tables(1)
      Set cl1 = tbl.Cell(iSelectionRowStart, 4)
      Set cl2 = tbl.Cell(iSelectionRowEnd, 4)
      Set rng = cl1.Range.Duplicate
      rng.End = cl2.Range.End
      rng.text = ("SALE")
  
  End If
  Selection.Collapse Direction:=wdCollapseStart
  
  If ActiveDocument.Bookmarks.Exists("MacroStartPosition") = True Then
      ActiveDocument.Bookmarks("MacroStartPosition").Select
      ActiveDocument.Bookmarks("MacroStartPosition").Delete
  Else
      MsgBox "The original cursor position could not be restored."
  End If
  
  Selection.Collapse Direction:=wdCollapseStart
  </code></pre>
  
  <p>I tried to follow a similar code in Excel and apply it to Word, but I am getting errors. See below Excel.</p>
  
  <pre><code>ActiveCell.FormulaR1C1 = "SALE"
  Selection.AutoFill Destination:=Range("D3:D7"), Type:=xlFillDefault
  Range("D3:D7").Select
  </code></pre>