Hi.
Maybe this is a very stupid question, but, anyway.....
As far as I know, we can declare variables whose validity depends on their typology (local, global, etc...).
In any case, nevertheless, no variable's value is "Saved".
Let's assume I've the following code
Sub UserForm_Initialize()
Dim myvar as integer
If OptionButton1 = True Then
myvar = 1
Else
Myvar = 0
end if
end sub
Let's assume that users click OptionButton1 (=True)
When code is terminated or form closed, when I load userform1 again, Myvar won't have value 1, unless I click OptionButton1 again.
So, to save users choices until next change, I've solved my problem by mean of "Control source" property.
(OptionButton1.ControlSource="Sheet1!A1" and, in "Initialize" event:
If Worksheets("Sheet1"
.Range("A1"
=1 Then
OptionButton1.value=False
else
OptionButton1.value=True
etc.....)
In fact, value of cells is not temporary and it's saved with all data in worksheet.
I'm sure there's another way to save data in variables, but I don't know.
Thank you for your kind suggestions.
Regards.
Nick.
Maybe this is a very stupid question, but, anyway.....
As far as I know, we can declare variables whose validity depends on their typology (local, global, etc...).
In any case, nevertheless, no variable's value is "Saved".
Let's assume I've the following code
Sub UserForm_Initialize()
Dim myvar as integer
If OptionButton1 = True Then
myvar = 1
Else
Myvar = 0
end if
end sub
Let's assume that users click OptionButton1 (=True)
When code is terminated or form closed, when I load userform1 again, Myvar won't have value 1, unless I click OptionButton1 again.
So, to save users choices until next change, I've solved my problem by mean of "Control source" property.
(OptionButton1.ControlSource="Sheet1!A1" and, in "Initialize" event:
If Worksheets("Sheet1"
OptionButton1.value=False
else
OptionButton1.value=True
etc.....)
In fact, value of cells is not temporary and it's saved with all data in worksheet.
I'm sure there's another way to save data in variables, but I don't know.
Thank you for your kind suggestions.
Regards.
Nick.