Pop-Up Calendar with UserForm

MikeeRDX

Board Regular
Joined
Feb 16, 2014
Messages
98
Hi,

I have a created a UserForm with a Date textbox and would like to add a pop-up calendar to help with selecting and populating the date into the textbox. I already have the calendar set up to pop-up with I click on a button but can't get the date to drop in the textbox. Would someone please help? My textbox is called "txtEdate". Calendar is named "MyCal" and "UserForm1".
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Have you tried?
Code:
txtEdate.value = MyCal.value
 
Upvote 0
The button that I created to pull up the pop-calendar has this code written for it: The use an image of a calendar to cover this button for look. Then, I position the command button next to the textbox (txtIdate). By the way, I have several date fields and intend on creating separate calendar and button for each textbox.

Private Sub btnEdate_Click()
MyCal.lblCtrlName = "txtEdate"
MyCal.lblUF = "Userform1"
MyCal.Show
End Sub
 
Upvote 0
If I use this code, I get an Object Required error:

Private Sub fCal_DateClick(ByVal DateClicked As Date)
txtEdate.Text = DateClicked
Me.Hide
Exit Sub
 
Upvote 0
Help me understand!

How many userforms do you have?

Is the textbox in the same userform as the calendar control? if they are not you have to refer to each control with its full name like
Code:
Userform1.txtEdate.value = Userform2.Calendar1.value
 
Last edited:
Upvote 0
Ok....Each calendar is on its own userform...then I renamed them as MyCal. Then MyCal2 for the next date textbox, etc...
 
Upvote 0
I followed a YouTube blogger on creating the code and he used a loop function and this is what he has. I tried using the same code but the date clicked doesn't capture in the textbox. Nothing happens

Private Sub fCal_DateClick(ByVal DateClicked As Date)
For Each uf In VBA.UserForms
If uf.Name = MyCal.lblUF Then
For Each ctl In uf.Controls
If ctl.Name = MyCal.lblCtrlName Then
ctl.Value = DateClicked

Me.Hide
End If
Next ctl
End If
Next uf

End Sub
 
Upvote 0
IT WORKED!!!

I used this code:

Private Sub fCal_DateClick(ByVal DateClicked As Date)
UserForm1.txtEdate.Text = DateClicked

End Sub

Oh my goodness....YOU did it! It worked for my first date text box. Now let me try and see if it will work on the others....... cross our fingers....
 
Upvote 0
It worked!!! They're all working now. Thank you so much for all your help!

I also have another post that I'm still trying to get a resolution for. It's the post regarding using VBA to update an existing record or data. I don't know how to post the link to the post in here. Sorry.
 
Upvote 0

Forum statistics

Threads
1,226,503
Messages
6,191,422
Members
453,657
Latest member
DukeJester

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top