One of the ways to store a variable when closing and re-opening workbook is with CustomDocumentProperties.
The variable changes depending on selection (one of 3 values).
Selection is from userform option buttons.
Below code works only for 1 selection and then have to exit form.
How can it work for alternating selection when userform is still on.
The variable changes depending on selection (one of 3 values).
Selection is from userform option buttons.
Below code works only for 1 selection and then have to exit form.
How can it work for alternating selection when userform is still on.
VBA Code:
Private Sub option_button_Full_Click()
If Err Then
Err.Clear
With ActiveWorkbook.CustomDocumentProperties("my_property")
.Delete
End With
End If
With ActiveWorkbook.CustomDocumentProperties
.Add Name:="my_property", LinkToContent:=False, Type:=msoPropertyTypeString, Value:="value_1"
End With
MsgBox ThisWorkbook.CustomDocumentProperties("my_property").Value
End Sub
Private Sub option_button_Partial_Click()
If Err Then
Err.Clear
With ActiveWorkbook.CustomDocumentProperties("my_property")
.Delete
End With
End If
With ActiveWorkbook.CustomDocumentProperties
.Add Name:="my_property", LinkToContent:=False, Type:=msoPropertyTypeString, Value:="value_2"
End With
MsgBox ThisWorkbook.CustomDocumentProperties("my_property").Value
End Sub
Private Sub option_button_Manual_Click()
If Err Then
Err.Clear
With ActiveWorkbook.CustomDocumentProperties("my_property")
.Delete
End With
End If
With ActiveWorkbook.CustomDocumentProperties
.Add Name:="my_property", LinkToContent:=False, Type:=msoPropertyTypeString, Value:="value_3"
End With
MsgBox ThisWorkbook.CustomDocumentProperties("my_property").Value
End Sub