Can I save variables as part of and Excel file
Can I save variables as part of and Excel file
(OP)
I'm trying to save some program data so that the next time I run a VBA program the form has some of the controls set as they were the last time it was run in that document. I know I could create a separate worksheet to store it but I'd really like it invisible.
In Word I can use ThisDocument.Variable.AddItem(VariableName) to create a place to store a varaible. In AutoCAD I can use Name = ThisDrawing.GetVariable("USERS1") as a place to get a string of data. Is there anything in Excel that is similar where I can store data that gets saved with the workbook?
In Word I can use ThisDocument.Variable.AddItem(VariableName) to create a place to store a varaible. In AutoCAD I can use Name = ThisDrawing.GetVariable("USERS1") as a place to get a string of data. Is there anything in Excel that is similar where I can store data that gets saved with the workbook?





RE: Can I save variables as part of and Excel file
RE: Can I save variables as part of and Excel file
RE: Can I save variables as part of and Excel file
If for some reason you don't like that there are a number of other ways. Here is one: Store your variables into named formula's.
For example let's say you have a variable MyVariable that you work with.
CODE
double MyVariable
MyVariable = 43.1
You can store and retrieve into a named formula as follows:
Store your variable as follows:
CODE
Sheets("Sheet1").names.add Name:="MyVariableStored", RefersToR1C1:="=" + cstr(MyVariable)
' Note that the RefersToR1C1 expects and excel type formula
' so we created a formula by concatenting "=" with the string version of MyVariable
To retrieve your variable
CODE
MyVariable=evaluate(Sheets("Sheet1").names("MyVariableStored").RefersToR1C1)
' Note the evaluate function converts formula back to value
=====================================
Eng-tips forums: The best place on the web for engineering discussions.
RE: Can I save variables as part of and Excel file
Ken
RE: Can I save variables as part of and Excel file