Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() NEWBIE question: I run code that retrieves an integer value 'hidden' in a cell on one of my worksheets. The code uses thus value, then increments it by 1 before storing the new value back in the 'hidden' cell. Next time I run the code, it uses the incremented value even if I've closed and reopened the application. All works well, but.... I'd rather store the value in the code, not in the 'hidden' cell. (so I can better disallow certain values and manipulate other ones.) How can I store the value in the code so that it increments as desired but doesn't reset everytime I open the application? much thanks Ginger |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Use a static variable within your Sub or ont top of your Module
It will retain its current value between calls. Static lCounter as Long HTH -- AP "Giselle" a écrit dans le message de news: ... NEWBIE question: I run code that retrieves an integer value 'hidden' in a cell on one of my worksheets. The code uses thus value, then increments it by 1 before storing the new value back in the 'hidden' cell. Next time I run the code, it uses the incremented value even if I've closed and reopened the application. All works well, but.... I'd rather store the value in the code, not in the 'hidden' cell. (so I can better disallow certain values and manipulate other ones.) How can I store the value in the code so that it increments as desired but doesn't reset everytime I open the application? much thanks Ginger |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The key to this question is that you want to store it when the
application isn't running - and you cannot do this - at least, not without it physically being somewhere - a hidden cell would be one solution, using an INI file or the registry is another solution. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
He could have a special sheet for storing any values like this that he needs,
& write code to create this sheet before the workbook closes, & retrieve the information then delete/hide the sheet when the workbook opens. " wrote: The key to this question is that you want to store it when the application isn't running - and you cannot do this - at least, not without it physically being somewhere - a hidden cell would be one solution, using an INI file or the registry is another solution. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Agreed, but the original post implied not wanting to do this - although
I agree that rather than a hidden cell, I would have an entire hidden sheet! Never needs to be unhidden as the code can reference it anyway |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
storing macros ? | Excel Discussion (Misc queries) | |||
Storing a value to variable | Excel Discussion (Misc queries) | |||
storing value's | Excel Programming | |||
storing of VBA code | Excel Programming | |||
Storing Data in code? (relative primes to MOD as example) | Excel Programming |