Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Access a VBA global variable/constant from a worksheet cell

I want to declare several constants in VBA that should be accessible from the
worksheet cells.
Is it at all possible? I tried several combinations of GLOBAL, PUBLIC,
inside workbook/workbook_open, inside workbook/general, inside a user
module/general, inside a user module/some function. Can get the value
displayed in a MsgBox and the like, but whenever I try to assign it to a cell
I get the #NAME error. I know I could just assign it to some hidden cell in
the workbook but I thought there must be a cleaner solution...

Thanks in advance!
Lina
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default Access a VBA global variable/constant from a worksheet cell

You could make the cell value equal to the constant, but you can't access it
from the cell. What you can do is create a name for the constant with
Insert/Name/Define and access that from a cell. Create a name called glad,
and in the Refers to: box put your constant, Gladiator, for example. In your
cell type = glad and the word Gladiator will appear.

Mike F
"Lina" wrote in message
...
I want to declare several constants in VBA that should be accessible from
the
worksheet cells.
Is it at all possible? I tried several combinations of GLOBAL, PUBLIC,
inside workbook/workbook_open, inside workbook/general, inside a user
module/general, inside a user module/some function. Can get the value
displayed in a MsgBox and the like, but whenever I try to assign it to a
cell
I get the #NAME error. I know I could just assign it to some hidden cell
in
the workbook but I thought there must be a cleaner solution...

Thanks in advance!
Lina



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Access a VBA global variable/constant from a worksheet cell

Both suggestions were great, that solved it!
Thanks a lot!
Lina

"Lina" wrote:

I want to declare several constants in VBA that should be accessible from the
worksheet cells.
Is it at all possible? I tried several combinations of GLOBAL, PUBLIC,
inside workbook/workbook_open, inside workbook/general, inside a user
module/general, inside a user module/some function. Can get the value
displayed in a MsgBox and the like, but whenever I try to assign it to a cell
I get the #NAME error. I know I could just assign it to some hidden cell in
the workbook but I thought there must be a cleaner solution...

Thanks in advance!
Lina

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stopping a constant variable cell from being copied. Link New Users to Excel 3 May 15th 07 03:35 AM
Global Array Constant Cory Excel Programming 5 May 11th 07 03:14 PM
How do I access a "Global Variable" of one Workbook from another?? [email protected] Excel Programming 1 May 23rd 06 06:38 PM
why is it saying sheetcnt is "variable not defined" how to do a global variable to share over multiple functions in vba for excel? Daniel Excel Worksheet Functions 1 July 9th 05 03:05 AM
Referring to a local or global variable or constant dynamically? PC[_2_] Excel Programming 1 September 15th 03 02:31 PM


All times are GMT +1. The time now is 09:27 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"