View Single Post
 
Old 05-19-2021, 05:05 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,977
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Try this
Code:
Sub test2()
  Dim aTable As Table, iRow As Integer, sPrefix As String, aRow As Row
  Dim sC1 As String, sC2 As String, sC3 As String
  
  sC2 = "Name"
  sC3 = "State"
  sPrefix = "Zz"
  
  If ActiveDocument.Tables.Count > 0 Then
    Set aTable = ActiveDocument.Tables(1)
    aTable.Columns.Width = InchesToPoints(1.66)
    aTable.Columns.Add
    aTable.Columns.Add
    aTable.Cell(1, 2).Range.Text = sC2
    aTable.Cell(1, 3).Range.Text = sC3
    For iRow = 2 To aTable.Rows.Count
      Set aRow = aTable.Rows(iRow)
      sC1 = Split(aRow.Cells(1).Range.Text, vbCr)(0)
      aRow.Cells(2).Range.Text = sPrefix & sC1 & sC2
      aRow.Cells(3).Range.Text = sPrefix & sC1 & sC3
    Next iRow
  End If
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote