programme variables in excell VBA

K

kurt hansen

Hello

Is there a variable area Text) in Excel VBA precsented under VBA
locals to be used for programmer purpose only (this may not could
interfer with excell or VBA) and how do I accessed it.
ex. me.uservariabes.variables1

it is urgent that this will be saved together with the file.

regards

Kurt
 
G

Guest

Application.Names.Add "MYVARIABLE","MYVALUE"

This creates a name/variable MYVARIABLE with the value MYVALUE and it gets
saved with the workbook. BUT only string values may be used. In order to
query the value use:

Evaluate(Application.Names("MYVARIABLE").Value)

Without Evaluate, a formula rather than a value is returned.

Also. consider using Custom properties for variables that you do not want to
shore in cells.
 
B

Bob Phillips

No there isn't.

If you want to preserve information across different sessions, there are 3
easy ways

- write it to another file an d the read it back at the session start
- write it to a workbook name and read it back at the start
- write it to a worksheet cell and read it back at the start.

The first two would need to cater for non-existence, the third only for
being empty.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
T

Tom Ogilvy

? BUT only string values may be used.

Application.Names.Add "MYVARIABLE",1000

works as well.

Names also have a visible property if you don't want the user to be able to
alter them in Insert=>Name=>Define (as an example).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top