Is there a way to give an Excel table a name that is worksheet-scoped instead of workbook-scoped?
Solution 1:
For completeness, I'm pretty sure the answer to my question is "no".
Of course I'll un-accept this and accept an answer that shows that this is wrong, or one that explains why it's right.
Solution 2:
This may be helpful as a workaround:
'Given a worksheet name and a table(ListObject)name "prefix," return the actual name of the ListObject on the sheet.
'For example, if a worksheet containing a table called "ConfigTbl" is duplicated, it will get a name
'like "ConfigTbl3279" on the worksheet copy.
'This is a workaround for the fact that Tables are worksheet-level objects;
'Excel doesn't have local/worksheet-level tables.
'If you pass in one of the "Special Item" qualifiers, then the function will return the specified
'range as an object (e.g., "[#All]" for the whole table or "[#Headers]" for the column names).
'Returns #N/A if error.
Public Function tableName(wksht As String, tblName As String, Optional specialItem)
Dim lObj As ListObject
On Error GoTo ErrHandler
tblName = UCase(tblName)
For Each lObj In Worksheets(wksht).ListObjects
If (UCase(Left(lObj.Name, Len(tblName))) = tblName) Then
tableName = lObj.Name
If Not (IsMissing(specialItem)) Then Set tableName = Evaluate(tableName & specialItem)
Exit Function
End If
Next lObj
ErrHandler:
tableName = CVErr(xlErrNA)
End Function