Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,814
Default keep variable value after code quits

If I have code that prompts the user for some sort of input, is it possible
to have store the value of the variable so the next time the macro runs, it's
available?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,420
Default keep variable value after code quits

As long as next time is still within the same Excel session, create a public
variable and store it there.

--
__________________________________
HTH

Bob

"Steve" wrote in message
...
If I have code that prompts the user for some sort of input, is it
possible
to have store the value of the variable so the next time the macro runs,
it's
available?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default keep variable value after code quits

Store it in a public variable, or, if you want it the next time you open, a
cell

public savethis
sub()
ddd
savethis="OK"
end sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Steve" wrote in message
...
If I have code that prompts the user for some sort of input, is it
possible
to have store the value of the variable so the next time the macro runs,
it's
available?


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default keep variable value after code quits

If its a continuous segment of code, or one macro jumping to another yes.
Otherwise, I'd have the code write the value to a cell somewhere, and then
refer to that cell. (maybe do an if blank check or something)
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"Steve" wrote:

If I have code that prompts the user for some sort of input, is it possible
to have store the value of the variable so the next time the macro runs, it's
available?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default keep variable value after code quits

Steve

Refer the below link to get a better understand of variables and scope.
http://www.ozgrid.com/VBA/variable-scope-lifetime.htm

If this post helps click Yes
---------------
Jacob Skaria


"Steve" wrote:

If I have code that prompts the user for some sort of input, is it possible
to have store the value of the variable so the next time the macro runs, it's
available?

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
can i link a variable cost code with a variable sum I need help!! Excel Discussion (Misc queries) 0 August 1st 08 11:40 AM
Excel quits unexpectedly Simon Brown Excel Worksheet Functions 1 May 4th 07 11:36 PM
Circular Reference quits atompson Excel Discussion (Misc queries) 3 September 8th 06 08:26 PM
VBA Code - NAME SEVERAL VARIABLE cells Danny Excel Worksheet Functions 0 October 14th 05 06:15 PM
variable code?? Paul Excel Discussion (Misc queries) 1 April 5th 05 06:37 PM


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

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"