Tech Support Guy banner
Status
Not open for further replies.

Solved: VBA (Excel) code one userform for more forms

3K views 1 reply 1 participant last post by  Keebellah 
#1 ·
Hi,:confused::eek:
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.
:confused:
 
See less See more
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top