-
1 Attachment(s)
Close VBA form
Enclosed Excel macro file (CalendarFormHelp.xlms).
I will like that after pressed de X button in the form, the form closed, without entering any date.
Leaving the cell C7 empty.
Just without entering any date (just empty).
Is this possible?
Thanks for the suggestion.
-
Welcome to VBAX Vitorio. I notice that two of the contributors to the Calender form are Graham Mayor and Greg Maxey, both are active members here. One or both could be along shortly.
-
Hope to see then. Thanks.
-
File in first post.
Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Thanks to Dan McGovern for suggesting and supplying this code
Dim TriggerCells As Range
' The cells you click in to display the calendar
Set TriggerCells = Range("C7")
If Not Intersect(TriggerCells, Target) Is Nothing Then
ActiveCell.value = CalendarForm.GetDate(FirstDayOfWeek:=Monday, SaturdayFontColor:=RGB(250, 0, 0), SundayFontColor:=RGB(250, 0, 0))
End If
End Sub
Maybe something like this:
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
' If CloseMode = 0 Then
' Cancel = True
' DateOut = SelectedDateIn
' Me.Hide
' End If
'End Sub
-
If you just want to leave it as it is:
Code:
If Not Intersect(TriggerCells, Target) Is Nothing Then Dim SelectedDate As Date
SelectedDate = CalendarForm.GetDate(FirstDayOfWeek:=Monday, SaturdayFontColor:=RGB(250, 0, 0), SundayFontColor:=RGB(250, 0, 0))
If SelectedDate <> 0 Then ActiveCell.value = SelectedDate
End If
-
This week I am going to test the recommendations made, since I am out of town. As soon as finish I will le you know the results.
Thanks to all for your help.
-
1 Attachment(s)
You can use the QueryClose event to pass a global variable when you click on the [X] that says to clear the cell
Search for bClearDate in the code
Code:
Public bClearDate As Boolean ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<
Code:
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
Cancel = True
bClearDate = True ' <<<<<<<<<<<<<<<<<<
Me.Hide
Unload Me
End If
End Sub
-
Just return this week.
Tested the recommended recommendations. Thanks to all for the help provided , specially for McGovern for answer the special request to help.
Solutions provided solved my request.
Until the next time!!!
-
-
-
From above post, #4
"Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' Thanks to Dan McGovern for suggesting and supplying this code
Dim TriggerCells As Range" ...