View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Dennis Benjamin Dennis Benjamin is offline
external usenet poster
 
Posts: 12
Default Public variables and scope

Hey All

I'm learning VBA in Excel and am confused about variable scope. I have
declared a variable at the top of the thisWorkBook module as follows:

Option Explicit
Public mAb

when I add mAb to the Watchlist, and select Context = thisWorkbook, I can
see the contents. When I add another copy to the Watchlist, selecting
Context=(All Modules) it shows up as "Expression not defined". I am guessing
that this is the reason I am unable to store values in mAb from inside Subs
in my UserForms - they don't know about the variable. Is there some setting
that would cause this behavior? How can I share a variable between my
thisWorkBook and a UserForm?

Thanks!