I need to insert data into specific cells in a word table that already exists from an excel spreadsheet. The columns will always stay the same just the rows referenced can change.
I will always insert values from column A such as A3 into my first word table in the first row,second cell. Does anyone know how you do this? I did try using this example as a basis but it didn't work out too well : vba - Taking data from Excel and inserting into a pre existing Word table? - Stack Overflow. Has anyone got a simple method to get it in the correct cell?
Code snippet below:
I will always insert values from column A such as A3 into my first word table in the first row,second cell. Does anyone know how you do this? I did try using this example as a basis but it didn't work out too well : vba - Taking data from Excel and inserting into a pre existing Word table? - Stack Overflow. Has anyone got a simple method to get it in the correct cell?
Code snippet below:
Code:
[/FONT][/COLOR][/SIZE][COLOR=#000000][FONT=Tahoma][SIZE=2]
[/SIZE][/FONT][/COLOR]
[COLOR=#000000][FONT=Tahoma][SIZE=2]'Get the Excel range
Set xlRng = Selection
'Count the rows and columns that the table has in the word document
With .Tables(1)
For i = 1 To xlRng.Rows.EntireRow.Count
For x = 1 To xlRng.EntireColumn.Count
.Cell(i, x).Range.Text = xlRng.Cells(i, x).Value
'Print value of integer to check it has a value assigned to it
' Debug.Print i
Next
Next
End With
' With .Tables(2)
' For ii = 1 To xlRng.Rows.EntireRow.Count
' For xx = 1 To xlRng.EntireColumn.Count
' .Cell(ii, xx).Range.Text = xlRng.Cells(ii, xx).Value
' Next
' Next
.Save