I have a macro that I want it to look at a table and if there is data in the table then I want it to complete a VLookup but if there is no data in the table then I want it to end the if statement and move to the next statement (there are 3 tables in total the macro moves through). It is always possible for one or more of the tables to not have data.
Currently I have the below written for the first table but when there is no data it just throws an error message.
Workbooks("Letter_Mail Merge_Template.xlsm").Worksheets("MailMerge_Device").Activate
If ActiveSheet.ListObjects("Table24").DataBodyRange.Rows.Count >= 1 Then
Workbooks("Letter_Mail Merge_Template.xlsm").Worksheets("MailMerge_Device").Range("L2:L" & Cells(Rows.Count, "H").End(xlUp).Row).Formula = "=VLOOKUP([@[Full Name]],campusship.csv!$E:$F,2,FALSE)"
Else
End If
If there is data in the table everything works perfectly.
Currently I have the below written for the first table but when there is no data it just throws an error message.
Workbooks("Letter_Mail Merge_Template.xlsm").Worksheets("MailMerge_Device").Activate
If ActiveSheet.ListObjects("Table24").DataBodyRange.Rows.Count >= 1 Then
Workbooks("Letter_Mail Merge_Template.xlsm").Worksheets("MailMerge_Device").Range("L2:L" & Cells(Rows.Count, "H").End(xlUp).Row).Formula = "=VLOOKUP([@[Full Name]],campusship.csv!$E:$F,2,FALSE)"
Else
End If
If there is data in the table everything works perfectly.