Tags: cani, declare, excel, microsoft, module, msdn, public, software, thisworkbook, variable, variables, workbook

Public Variable in ThisWorkbook

On Microsoft » Microsoft Excel

1,797 words with 2 Comments; publish: Wed, 04 Jun 2008 02:02:00 GMT; (3064,306.64, « »)

I want to declare some public variables as soon as I open the workbook. Can

I do that in "ThisWorkbook" or do I need to put it in a module and have

"ThisWorkbook" Open event call a routine to set the public variables?

All Comments

Leave a comment...

  • 2 Comments
    • If the variables are going to be used in procedures outside the

      ThisWorkbook module, you should declare them in the declarations

      section of a regular code module, and initialize them in the Open

      event procedure.

      Cordially,

      Chip Pearson

      Microsoft MVP - Excel

      Pearson Software Consulting, LLC

      www.cpearson.com

      "DRKML" <DklineCLUChFC.excel.questionfor.info.Comcast.net> wrote in message

      news:usgYh3rPFHA.248.excel.questionfor.info.TK2MSFTNGP15.phx.gbl...

      >I want to declare some public variables as soon as I open the

      >workbook. Can

      > I do that in "ThisWorkbook" or do I need to put it in a module

      > and have

      > "ThisWorkbook" Open event call a routine to set the public

      > variables?

      >

      #1; Wed, 04 Jun 2008 02:03:00 GMT
    • Thank you.

      "Chip Pearson" <chip.excel.questionfor.info.cpearson.com> wrote in message

      news:OmZwr6rPFHA.3988.excel.questionfor.info.tk2msftngp13.phx.gbl...

      > If the variables are going to be used in procedures outside the

      > ThisWorkbook module, you should declare them in the declarations

      > section of a regular code module, and initialize them in the Open

      > event procedure.

      >

      > --

      > Cordially,

      > Chip Pearson

      > Microsoft MVP - Excel

      > Pearson Software Consulting, LLC

      > www.cpearson.com

      >

      > "DRKML" <DklineCLUChFC.excel.questionfor.info.Comcast.net> wrote in message

      > news:usgYh3rPFHA.248.excel.questionfor.info.TK2MSFTNGP15.phx.gbl...

      >

      #2; Wed, 04 Jun 2008 02:04:00 GMT