Hi this is the code i am using works apart from first column comes back blank
Sub AddDataToTable5()
Dim ws As Worksheet
Dim tbl6 As ListObject
Dim tbl5 As ListObject
Dim newRow As ListRow
Dim currentRow As ListRow
Dim colIndex As Long
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Test Dry") ' Replace "Test Dry" with the actual sheet name
' Set Table 6
Set tbl6 = ws.ListObjects("Table6") ' Replace "Table6" with the actual name of Table 6
' Set Table 5
Set tbl5 = ws.ListObjects("Table5") ' Replace "Table5" with the actual name of Table 5
' Set the current row in Table 6 (assuming you want to use the last row)
Set currentRow = tbl6.ListRows(tbl6.ListRows.Count)
' Add a new row to Table 5
Set newRow = tbl5.ListRows.Add
' Copy values from cells B10 to H10 to the new row in Table 5
For colIndex = 2 To 8 ' Columns B to H
' Copy values
newRow.Range(1, colIndex - 0).Value = ws.Range("B10:H10").Cells(1, colIndex).Value
Next colIndex
' Copy font properties and alignment from Table 6 to the new row in Table 5
For colIndex = 1 To tbl6.ListColumns.Count
' Copy font properties
newRow.Range(1, colIndex).Font.FontStyle = currentRow.Range(1, colIndex).Font.FontStyle
newRow.Range(1, colIndex).Font.Color = currentRow.Range(1, colIndex).Font.Color
newRow.Range(1, colIndex).Font.Size = currentRow.Range(1, colIndex).Font.Size
' Set horizontal alignment to center
newRow.Range(1, colIndex).HorizontalAlignment = currentRow.Range(1, colIndex).HorizontalAlignment
Next colIndex
' Clear cells G10:H10 in Table 6
ws.Range("G10:H10").ClearContents
End Sub
Any help would be great
Sub AddDataToTable5()
Dim ws As Worksheet
Dim tbl6 As ListObject
Dim tbl5 As ListObject
Dim newRow As ListRow
Dim currentRow As ListRow
Dim colIndex As Long
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Test Dry") ' Replace "Test Dry" with the actual sheet name
' Set Table 6
Set tbl6 = ws.ListObjects("Table6") ' Replace "Table6" with the actual name of Table 6
' Set Table 5
Set tbl5 = ws.ListObjects("Table5") ' Replace "Table5" with the actual name of Table 5
' Set the current row in Table 6 (assuming you want to use the last row)
Set currentRow = tbl6.ListRows(tbl6.ListRows.Count)
' Add a new row to Table 5
Set newRow = tbl5.ListRows.Add
' Copy values from cells B10 to H10 to the new row in Table 5
For colIndex = 2 To 8 ' Columns B to H
' Copy values
newRow.Range(1, colIndex - 0).Value = ws.Range("B10:H10").Cells(1, colIndex).Value
Next colIndex
' Copy font properties and alignment from Table 6 to the new row in Table 5
For colIndex = 1 To tbl6.ListColumns.Count
' Copy font properties
newRow.Range(1, colIndex).Font.FontStyle = currentRow.Range(1, colIndex).Font.FontStyle
newRow.Range(1, colIndex).Font.Color = currentRow.Range(1, colIndex).Font.Color
newRow.Range(1, colIndex).Font.Size = currentRow.Range(1, colIndex).Font.Size
' Set horizontal alignment to center
newRow.Range(1, colIndex).HorizontalAlignment = currentRow.Range(1, colIndex).HorizontalAlignment
Next colIndex
' Clear cells G10:H10 in Table 6
ws.Range("G10:H10").ClearContents
End Sub
Any help would be great