Hi,
Could anyone help me with the following code. It works when Table2 already contains data, but I have runtime error 91 when Table2 is blank. Why?
Could anyone help me with the following code. It works when Table2 already contains data, but I have runtime error 91 when Table2 is blank. Why?
Code:
Sub Integration()
Dim tbl1 As Range
Dim tbl2 As Range
Application.ScreenUpdating = False
Set tbl1 = Sheet1.ListObjects("Table1").DataBodyRange
Set tbl2 = Sheet2.ListObjects("Table2").DataBodyRange
If tbl2 Is Nothing Then
tbl1.Copy tbl2.Offset(0)
Else
tbl1.Copy tbl2.Offset(tbl2.Rows.Count)
End If
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub