Global Static and dynamic variable possible?

ShieBoon

Board Regular
Joined
May 3, 2011
Messages
111
Hi all, i need a variable for a date which is static, global, and the value of this variable can be changed via a userform. Is that possible?? :|

Excel 2003
Shie Boon
Thanks
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Anyway rorya, i'll be heading home already. I will come back to this thread tmr again. Thanks for all the replies!

Thanks,
Shie Boon
 
Upvote 0
I'm still waiting for feedback to my last code.
 
Upvote 0
Shie,

really you do want to use a cell in your sheet to store the value between sessions. You can name this cell in Excel (normal way)(Named Range) and then easily refer to it, even if rows are added to the sheet.


Code:
Range("MyNamedRange").value
 
Upvote 0
Hi rorya, sijpie,

rorya:
here is the textbox
Sub frm_MainBtns_Initialize(Optional ByRef Date as Date)
static DateStorage as Date

DateStorage = Date
load frm_MainBtns
' Set textbox to display the static variable's value
frm_MainBtns.txt_Date = DateStorage
frm_MainBtns.Show

End Sub

sijpie:
Well i do know i can use a cell, but i was thinking whether there were other ways not to :|

Thanks,
Shie Boon
 
Upvote 0
I know - that's what I posted. I have no idea if you're still stuck.
BTW, Date is a bad name for a variable as it's a data type and vba function name.
 
Upvote 0
Don't worry rorya, i've used another name for it. I used 'Date' in the codes i typed here to indicate that that's the date control.

Sorry, i guess i didn't understand your question? What did you mean by, "you haven't specified where the textbox is:"?

I'm currently still stuck because i need a method to store a value in Excel permanently. Meaning if i close Excel and start it up again, that value can still be accessed and changed. Is there such a method?

Thanks,
Shie Boon
 
Upvote 0
In a cell or defined name, or even a custom document property. A defined name is probably simplest if you don't want to use a cell for some reason.
 
Upvote 0
Does defined name refers to named range? If yes then,

Does it goes like this, i insert a value into a cell, create a named range for it, and delete the value from the cell, but i still can access the value from the named range?

Btw, i'm curious about what a custom document property means. If possible could you provide me with a brief explanation of it? Thanks :)

Thanks,
Shie Boon
 
Upvote 0
No, you use Name manager (or Insert-name-define, depending on version) to create a name and then in the refersto box enter =5 for example.
 
Upvote 0

Forum statistics

Threads
1,224,532
Messages
6,179,388
Members
452,908
Latest member
MTDelphis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top