frankt
02-17-2018, 04:57 AM
Hi, I am new to the forum but hope that maybe some of you smart people might know the answer to my problem? I attached a test.xlsm file in which I
- first run the userform1 in which I declare a public variable and pass a value to it.
- then close that userform1
- and then want to display that variable again when I push the BTN2 button that is on Sheet1 of the excel file
Something goes wrong because the value of the public variable is not shown?
thanx is you can help!!
code for the userform:
Public chosendate As Date
Private Sub CommandButton1_Click()
chosendate = DTPicker1.Value
MsgBox chosendate
Exit Sub
End Sub
code for the button on Sheet1
Private Sub CommandButton1_Click()
MsgBox "the date = " & chosendate
End Sub
- first run the userform1 in which I declare a public variable and pass a value to it.
- then close that userform1
- and then want to display that variable again when I push the BTN2 button that is on Sheet1 of the excel file
Something goes wrong because the value of the public variable is not shown?
thanx is you can help!!
code for the userform:
Public chosendate As Date
Private Sub CommandButton1_Click()
chosendate = DTPicker1.Value
MsgBox chosendate
Exit Sub
End Sub
code for the button on Sheet1
Private Sub CommandButton1_Click()
MsgBox "the date = " & chosendate
End Sub