I have hundreds of cells I need to copy paste from excel into a word table. I have figured out how to insert data (i.e. a "word table cell = 1" ) within excel VBA > word and that works fine, but my issue is copying a single excel cell into a single word table cell.
My code is currently:
'Do the For Loops here, WIP
For Each Cell In ActiveSheet.UsedRange.Cells
'do some stuff
For Each oRow In wdDoc.Tables(1).Rows
For Each oCell In oRow.Cells
' Set sCellText equal to text of the cell.
' Note: This section can be modified to suit
' your programming purposes.
If ((oCell.Column.Index Mod 2) = 0) Then
Else
'counter = counter + 1
'oCell.Range.Text = ThisWorkbook.Sheets(1).Cells(1, 2).Value
oCell.Range.Text = Cell
End If
Next oCell
Next oRow
Next
What it currently does is copy the first excel cell, to every single word table cell. When it hits the second excel cell, it overwrites every other word table cell.
Picture below of what is currently happening:
What I would like to happen: (Reads first excel cell, copy pastes to word table cell. - reads second excel cell, copy pastes to second word table cell.
Thanks,
Alex.