I am new to vba coding. I do not know if this is possible but can you copy a table (Daily) in 1 of my sheets to another workbook. I want the 2nd workbook to open, paste the selected data range into the table in the 2nd workbook, and then save and close the 2nd workbook.
Any help is much appreciated.
Private Sub CommandButton3_Click()
Dim ws As Sheets
Set ws = Sheet4
Dim tbl As ListObject
Dim dt As Integer
Dim line As String
Dim shift As String
Dim prod As Integer
Dim mydata As Workbook
Dim FileName As String
Dim lastrow As Long
FileName = "C:\Users\john.bauer\Desktop\Archive.xlsx"
Set tbl = ws.ListObjects("Daily")
With tbl
Range(1).Value = dt
Range(2).Value = line
Range(3).Value = shift
Range(4).Value = prod
End With
Set wb = wookbooks.Open(FileName).wb.woorksheet("Table").Active
lasrow = ActiveSheet.Cells(Row.Count, 1).End(x1up).Rows
Active.Cells(lastrow + 1, 1).Select
dt.Paste
Active.Cells(lastrow + 1, 2).Select
line.Paste
Active.Cells(lastrow + 1, 3).Select
shift.Paste
Active.Cells(lastrow + 1, 4).Select
prod.Paste
ActiveWorkbook.Save
ActiveWorkbook.Close savechanges = True