Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default storing a value in code


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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default storing a value in code

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default storing a value in code

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default storing a value in code

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default storing a value in code

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
storing macros ? Tim[_7_] Excel Discussion (Misc queries) 2 October 26th 07 02:54 AM
Storing a value to variable CLamar Excel Discussion (Misc queries) 0 June 16th 06 04:46 PM
storing value's ashw1984 Excel Programming 1 January 29th 06 04:20 PM
storing of VBA code kurt Excel Programming 4 January 13th 06 06:27 PM
Storing Data in code? (relative primes to MOD as example) jasonsweeney[_86_] Excel Programming 3 August 22nd 05 12:44 AM


All times are GMT +1. The time now is 08:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"