Hi,
My cryptic title means the following.
I have the following pop-up calendar code to fill a particular field in a userform:
Option Explicit
' ===================================================
' Code by Martin Green eMail martin@fontstuff.com
' Visit my Office Tips web site at www.fontstuff.com
' ===================================================
Private Sub cmdClose_Click()
' Close the UserForm
Unload Me
End Sub
Private Sub UserForm_Initialize()
' Check if active cell contains a date. If 'yes' show
' same date on calendar. If 'no' show today's date.
If IsDate(MedewForm.ActiveControl ) Then
Calendar1.Value = DateValue(MedewForm.ActiveControl )
Else
Calendar1.Value = Date
End If
End Sub
Private Sub Calendar1_Click()
' Transfer date selected on calendar to active cell
' and close UserForm.
MedewForm.ActiveControl = Calendar1.Value
Unload Me
End Sub
I would like to use this form for more than one form.
I imagine I could store the active userform name in a variable and replace MedewForm with this variable and then use it for any number of userforms but:
HOW DO YOU DO IT?
I have tried declaring a public constant but that did not work.
Any suggestions will be appreciated.
My cryptic title means the following.
I have the following pop-up calendar code to fill a particular field in a userform:
Option Explicit
' ===================================================
' Code by Martin Green eMail martin@fontstuff.com
' Visit my Office Tips web site at www.fontstuff.com
' ===================================================
Private Sub cmdClose_Click()
' Close the UserForm
Unload Me
End Sub
Private Sub UserForm_Initialize()
' Check if active cell contains a date. If 'yes' show
' same date on calendar. If 'no' show today's date.
If IsDate(MedewForm.ActiveControl ) Then
Calendar1.Value = DateValue(MedewForm.ActiveControl )
Else
Calendar1.Value = Date
End If
End Sub
Private Sub Calendar1_Click()
' Transfer date selected on calendar to active cell
' and close UserForm.
MedewForm.ActiveControl = Calendar1.Value
Unload Me
End Sub
I would like to use this form for more than one form.
I imagine I could store the active userform name in a variable and replace MedewForm with this variable and then use it for any number of userforms but:
HOW DO YOU DO IT?
I have tried declaring a public constant but that did not work.
Any suggestions will be appreciated.