ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Store variables in code just as you can w. constants? Available to read/edit? (https://www.excelbanter.com/excel-programming/400172-store-variables-code-just-you-can-w-constants-available-read-edit.html)

tskogstrom

Store variables in code just as you can w. constants? Available to read/edit?
 
Hi,
Constants can be set, but is there a way to change them dynamically
when needed, during the work in the workbook? To be used as variables
instead?

I want to store a number of ranges (actually, number of areas) and
have earlier tried to use "cell.value = [range].address" stored in
worksheet cells, but have stranded in that approach and search after
another way.

Best would be if they are accessible from all modules & subs, if
possible.

Kind regards
Tskogstrom


Leith Ross[_2_]

Store variables in code just as you can w. constants? Available to read/edit?
 
On Oct 28, 11:07 pm, tskogstrom wrote:
Hi,
Constants can be set, but is there a way to change them dynamically
when needed, during the work in the workbook? To be used as variables
instead?

I want to store a number of ranges (actually, number of areas) and
have earlier tried to use "cell.value = [range].address" stored in
worksheet cells, but have stranded in that approach and search after
another way.

Best would be if they are accessible from all modules & subs, if
possible.

Kind regards
Tskogstrom


Hello Tskogstrom,

Not sure why you can't use a variable, but that is what you are
describing. A constant's value is fixed during the compilation
process. By definition a constant doesn't change. To make it
accessible to all modules an proceduresn declare the constant or
variable in a Standard VBA Module using the keyword "Public". If you
need this to be seen by Class Modules also, use the "Global" keyword.

Sincerely,
Leith Ross


Bob Phillips

Store variables in code just as you can w. constants? Available to read/edit?
 
Just use public variables declared at the start of a standard code module.

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"tskogstrom" wrote in message
ups.com...
Hi,
Constants can be set, but is there a way to change them dynamically
when needed, during the work in the workbook? To be used as variables
instead?

I want to store a number of ranges (actually, number of areas) and
have earlier tried to use "cell.value = [range].address" stored in
worksheet cells, but have stranded in that approach and search after
another way.

Best would be if they are accessible from all modules & subs, if
possible.

Kind regards
Tskogstrom




Bob Phillips

Store variables in code just as you can w. constants? Available to read/edit?
 
Global?

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



"Leith Ross" wrote in message
ups.com...
On Oct 28, 11:07 pm, tskogstrom wrote:
Hi,
Constants can be set, but is there a way to change them dynamically
when needed, during the work in the workbook? To be used as variables
instead?

I want to store a number of ranges (actually, number of areas) and
have earlier tried to use "cell.value = [range].address" stored in
worksheet cells, but have stranded in that approach and search after
another way.

Best would be if they are accessible from all modules & subs, if
possible.

Kind regards
Tskogstrom


Hello Tskogstrom,

Not sure why you can't use a variable, but that is what you are
describing. A constant's value is fixed during the compilation
process. By definition a constant doesn't change. To make it
accessible to all modules an proceduresn declare the constant or
variable in a Standard VBA Module using the keyword "Public". If you
need this to be seen by Class Modules also, use the "Global" keyword.

Sincerely,
Leith Ross





All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com