You mentioned that but what I mentioned was that you need to add a test to see if the table is already present to avoid the errors.
Create a small table in a new blank workbook
Range B4 - F4 will be the header
B5 - F 6 is the date, two rows
Public Sub rng2Table()
Dim table As ListObject
If Tbl2rng = True Then Exit Sub
Range("B4:F6").Select
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$B$4:$F$6"), , xlYes).Name = _
"TestTable"
Range("B1").Select
End Sub
Public Function Tbl2rng() As Boolean
Dim table As ListObject
On Error GoTo noTable
Set table = ActiveSheet.ListObjects.Item("TestTable")
Tbl2rng = True
noTable:
Err.Clear
On Error GoTo 0
Range("B1").Select
End Function
If you place the above two macros in a blank workbook and run them:
rng2Table will create a table if does not already exists for the selected range
tbl2rng will convert the table to range if the table is present
The table name will be 'TestTable"
This is what I meant
Bookmarks