ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Permanent Variable? (https://www.excelbanter.com/excel-programming/274454-permanent-variable.html)

Random

Permanent Variable?
 
I am sure this is a pretty stupid question, but.....

Is there any way to store a permanent variable that can be incremented
over time between sessions and calls to the function? Meaning: I want
to store a number in a variable that can be accessed / added to / and
subtracted from from different functions over the course of many
workbook openings and closings.

For example: perVar would refer to a number like 1.

When function IncPerm() was run, it would add 1 to perVar so that
perVar = 2 for all other functions to reference from then on.

I know that I can store this value in a cell, but I am trying to avoid
that.


Any one have any ideas on this? All help is greatly appreciated.

Many thanks,

Random


Chip Pearson

Permanent Variable?
 
Random,

You might consider storing the value in a defined name.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Random" <Random@nwhere wrote in message
...
I am sure this is a pretty stupid question, but.....

Is there any way to store a permanent variable that can be

incremented
over time between sessions and calls to the function? Meaning:

I want
to store a number in a variable that can be accessed / added to

/ and
subtracted from from different functions over the course of many
workbook openings and closings.

For example: perVar would refer to a number like 1.

When function IncPerm() was run, it would add 1 to perVar so

that
perVar = 2 for all other functions to reference from then on.

I know that I can store this value in a cell, but I am trying to

avoid
that.


Any one have any ideas on this? All help is greatly

appreciated.

Many thanks,

Random




Random

Permanent Variable?
 
How would I reference that in VBA? I tried using the macro recorder,
but can't decipher what the verbage is for adding to and subtracting.

I have tried:
ActiveWorkbook.Names("Bob").Value = _
Right(ActiveWorkbook.Names("Bob").Value,
Len(ActiveWorkbook.Names("Bob").Value)-1) + 1

But that errors out....

I can't seem to find this in the help file either... any suggestions?

Random.


On Thu, 14 Aug 2003 20:11:31 -0500, "Chip Pearson"
wrote:

Random,

You might consider storing the value in a defined name.



Chip Pearson

Permanent Variable?
 
Create the name ThisName, and give it some initial value. Then use
the following to increment the value:

ThisWorkbook.Names.Add "TheName", _
Val(Mid(ThisWorkbook.Names("TheName").RefersTo, 2)) + 1


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"Random" <Random@nwhere wrote in message
...
How would I reference that in VBA? I tried using the macro

recorder,
but can't decipher what the verbage is for adding to and

subtracting.

I have tried:
ActiveWorkbook.Names("Bob").Value = _
Right(ActiveWorkbook.Names("Bob").Value,
Len(ActiveWorkbook.Names("Bob").Value)-1) + 1

But that errors out....

I can't seem to find this in the help file either... any

suggestions?

Random.


On Thu, 14 Aug 2003 20:11:31 -0500, "Chip Pearson"


wrote:

Random,

You might consider storing the value in a defined name.






All times are GMT +1. The time now is 08:37 PM.

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