Can a worksheet object be declared globally in Excel VBA?

后端 未结 6 1373
余生分开走
余生分开走 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:38

    Edit: The comment by Alistair Knock is correct, I should have read the question thoroughly - of course my answer is not valid for objects, only for types like string or integer. For objects you need a function or sub that creates an instance.


    Yes, you can, I recently did it. If you define your definitions as Public you can use them directly in your other modules (within the same workbook, of course).

    Maybe the best approach is to have a seperate module Globals and put them there.

提交回复
热议问题