VBA – Open Monthview Calanedar to enter a date in a Userform textbox

wcm69

Board Regular
Joined
Dec 25, 2016
Messages
112
Hoping someone can help.

I have a VBA User form with a text box named: txtDate

I would like my Monthview Calendar (already built) named: frmCalendar to open when the user enters the (cursor into the) text box.

I would then like the user to be able to pick a date from the Monthview Calender which will transfer to the textbox (txtDate) – then unload/close.

Note. I have a separate Command button on the form which I will use to enter all the information on the userform.

I have seen this question asked online a few times but none of the answers/solutions are working for me. I’m hoping someone can help me out with the correct VBA code for this one including the relevant modules to place the codes in :confused:.

The code I’m currently using only opens the calendar after I have entered a value in the text box then delete it – then it opens the calendar but does not allow a date to be transferred to the text box. Code in the Userform module.

'
Sub SetmeRec()

Dim DateCus As Range

On Error GoTo SetmeRec_Error

Set DateCus = Sheet3.Cells(Rows.Count, 6).End(xlUp).Offset(0, -1)

DateCus = frmCalendar.Val(Me.txtONum)
DateCus.Offset(0, -1) = Me.cboReceiving
DateCus.Offset(0, -2) = Format(Me.txtDate.Value, "dd/mm/yyyy")

On Error GoTo 0

Exit Sub

SetmeRec_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure SetmeRec of Form frmReceiving"

End Sub

As usual, any help is greatly appreciated.

Many thanks in advance :)
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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