mmetzinger
Board Regular
- Joined
- Dec 30, 2010
- Messages
- 61
OK, so I have the following code in my project that creates a table for a find/copy/paste operation performed later on
This code works great but my issue is if the user runs the macro again without closing the original workbook the macro will blow up because it will try and create a table on top of the table that already exits.
So what I need to do is put something like a basic if/then statement to check and see if the table exists but I don't know how to call the table.
Can someone help
Example Result
Code:
Range("A1", LastCG).Select
Range("C6").Activate
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1", LastCG), , xlYes). _
Name = "Table1"
Range("Table1[[#Headers],[Enroller Name]]").Select
This code works great but my issue is if the user runs the macro again without closing the original workbook the macro will blow up because it will try and create a table on top of the table that already exits.
So what I need to do is put something like a basic if/then statement to check and see if the table exists but I don't know how to call the table.
Can someone help
Example Result
Code:
If object.table1 exists then
else
Range("A1", LastCG).Select
Range("C6").Activate
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1", LastCG), , xlYes). _
Name = "Table1"
Range("Table1[[#Headers],[Enroller Name]]").Select
end if