This table has two the first two columns which I want to paste in another table which is "table9"
the rows on both tables can vary however this is the sequence of the task. First clear table9, then take the first two columns of table3 and paste them into the first two columns of table9.
I tried this using the following from help on my other questions:
Private Sub CommandButton2_Click() 'ActiveX button's click event handler
Dim lo As ListObject, TABLE_NAME, arr
For Each TABLE_NAME In Array("IndividualProfitLoss|Table9") 'and so on
On Error Resume Next
arr = Split(TABLE_NAME, "|")
Set lo = Me.Parent.Sheets(arr(0)).ListObjects(arr(1))
If Err.Number <> 0 Then
MsgBox TABLE_NAME & " was not found. Check the table name", vbCritical + vbOKOnly, "Sub CommandButton1_Click()"
Exit Sub
End If
On Error GoTo 0
If Not lo.DataBodyRange Is Nothing Then lo.DataBodyRange.Delete
Next
Dim Table3 As ListObject, Table9 As ListObject
Dim h As ListColumn
Set Table3 = Receipt.ListObjects("Table3")
Set Table9 = IndividualProfitLoss.ListObjects("Table9")
'loop over the headers from the source table
For Each h In Table3.ListColumns
'is the column name in the "excluded" list?
If IsError(Application.Match(h.Name, Array("??? ???????", "??????"), 0)) Then
'ok to copy...
h.DataBodyRange.Copy Table9.ListColumns(h.Name).DataBodyRange(1)
End If
Next h
End Sub
this gives me runtime error 424. "Object Required".
any help would be appreciated
EDIT: I believe the code to clear table9 works but pasting the values of the first two columns of table3 into table9 is a problem. So a help there would be appreciated :)