Some help with a userform

Diving_Dan

Board Regular
Joined
Oct 20, 2019
Messages
161
Hi again,

I have a userform that is a pop up calendar that puts the date clicked into a cell on the worksheet. That all works perfectly.

I am creating another userform to add data to my workbook. I am struggling to get the calendar to pop up when I click into the text box. How do I code this?

The calendar is called frmCalendar and the new form i'm creating is called frmAddStaff

Thanks in advance.
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
In the frmAddStaff userform module, assuming the text box is named txtDate:
VBA Code:
Private Sub txtDate_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    frmCalendar.Show
End Sub
 
Upvote 0
The problem I am now having is that when the date is input into the textbox that it is in the format of mm/dd/yyyy. I am struggling to find code so it will be in the format of dd/mm/yyyy.

Can anyone help?
 
Upvote 0
Try this:
VBA Code:
Private Sub txtDate_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
    frmCalendar.Show
    txtDate.Value = Format(txtDate.Value, "dd/mm/yyyy")
End Sub
If that doesn't work please post your frmCalendar userform code, or the link to where you got it from.
 
Upvote 0

Forum statistics

Threads
1,215,493
Messages
6,125,134
Members
449,206
Latest member
burgsrus

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