ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scope of Tables Is Workbook, Not WorkSheet (https://www.excelbanter.com/excel-programming/400113-scope-tables-workbook-not-worksheet.html)

Christopher King[_2_]

Scope of Tables Is Workbook, Not WorkSheet
 
If you use tables in Excel 2007, you may find this useful to know: The scope
of a table is "WorkBook", not "WorkSheet". This is unexpected. In VBA, to
refer to a table (a "list" in earlier versions of Excel), its worksheet
object must be specified, as in the following:
Debug.Print ActiveSheet.ListObjects("Schedule").Name
This suggests that the scope is WorkSheet. However, the Name Manager, on
the Formulas tab, shows that the scope is WorkBook. To demonstrate that that
is the case, copy a worksheet containing a table (leave both versions in the
same workbook). The tables in the copy are renamed. For example, in my
case, the table "Schedule" was renamed "Schedule10" on the copied sheet.
Consequently, the line of code above won't work on a copy of the original
sheet. That makes tables less powerful than they could have been, at least
from the point of view of VBA programming. I wish Microsoft would consider
changing that behavior in a Service Pack.
Chris



All times are GMT +1. The time now is 06:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com