View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Fredrik Wahlgren Fredrik Wahlgren is offline
external usenet poster
 
Posts: 339
Default VB to set a constant in another procedure


wrote in message
oups.com...
I'd like to know if it's possible to use a VBA procedure to set a
variable or constant that will be used by another VBA procedure. I'd
like to do this without referencing a value in a worksheet cell.

Ben


Insert a module and declare something like

Public Myglobal As Long

You can also define a name that refers to your global value like this
ActiveWorkbook.Names.Add Name:="MyGlobal", RefersToR1C1:="=999"
This possibility can be useful if you want to preserve the value when you
exit Excel.
(without referencing a value in a worksheet cell)

/Fredrik