Can a worksheet object be declared globally in Excel VBA?

后端 未结 6 1429
余生分开走
余生分开走 2021-01-05 02:32

I\'m refactoring a number of modules in an Excel 2003 workbook and the same set of worksheets are declared in each procedure in each module; I\'d like to just declare them o

6条回答
  •  半阙折子戏
    2021-01-05 02:33

    It's a long time ago, but better late than never ;-) I don't know if that works in Excel 2003 (tested it with 2007):

    You don't even need to declare worksheets in the code, because they are already declared. I'm working with a German version of Excel and I can access a worksheet by typing "Tabelle1.Cells(...) ...". I assume in the English version it is something like "Table1" or "Sheet1".

    You can also change these names. In the Visual Basic Editor have a look at the Microsoft Excel Objects of your VBA-Project. (They are right above your Modules and UserForms in the VBA-Project view). There are the Worksheet-Objects of your workbook. Select a sheet and activate the Properties Toolwindow. There you can edit the name of the sheet and access it by that name in your code.

提交回复
热议问题