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 date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,215,430
Messages
6,124,853
Members
449,194
Latest member
HellScout

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