Hello,
I have a user form built in VBA Excel that uses a few textboxes with date values.
For these date values I am using a datepicker.
When the user clicks on the date textbox this brings up the calendar form to the screen so that the user can select the date value.
However, when the user does not want to choose the date and just clicks on X at the right top corner of the calendar form this closes the form, as expected, but also still inputs the value in the textbox.
What I am trying to achieve is that when the user clicks on X, this just closes the calendar form and DOES NOT INPUT the date value in the textbox.
Does anybody have any idea how this can be achieved?
Thank you!
If that's of any help here, this is the code behind the calendar form:
Private Sub UserForm_Initialize()
If IsDate(ActiveCell.Value) Then
Me.MonthView1.Value = ActiveCell.Value
End If
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub MonthView1_DateClick (ByVal DateClicked as Date)
On Error Resume Next
Dim cell as Object
For Each cell in Selection.Cells
cell.Value = DateClicked
Next cell
Unload Me
End Sub
There is also some code behind each of the date textboxes mainly to ensure the logical checks are in place (for example, not dates in the future are allowed etc).
Thank you again!
Bookmarks