Pop up macro calendar on cell change

e561414

New Member
Joined
Mar 12, 2014
Messages
35
Hello everyone.
I'll start with the credits; there's a really useful calendar code here:
VBA Express : Excel - Userform Calendar Control

Everything works fine, this part right here triggers it whenever I touch a cell with that format:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim DateFormats, DF
    DateFormats = Array("dd/mm/yy;@", "mmmm d yyyy")
    For Each DF In DateFormats
        If DF = Target.NumberFormat Then
            If CalendarFrm.HelpLabel.Caption <> "" Then
                CalendarFrm.Height = 191 + CalendarFrm.HelpLabel.Height
            Else: CalendarFrm.Height = 191
                CalendarFrm.Show
            End If
        End If
    Next
End Sub

But I actually want it to show up whenever the user tries to write something on the cell instead of showing up everytime I touch it. How can I do that without messing it up?

Thank you all in advance.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You need _Change not _SelectionChange.

Hello Peter, I applied your suggestion and it triggers the macro only after I'm done entering the value in the cell, for instance, after hitting Enter, clicking outside or hitting Delete.

I just figured out that what I really need is to trigger the macro right when the user presses a key or double clicks.

Is this possible through VBA?
 
Upvote 0
Try this with double clicks

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim DateFormats, DF
    Cancel = True
    DateFormats = Array("dd/mm/yy;@", "mmmm d yyyy")
    For Each DF In DateFormats
        If DF = Target.NumberFormat Then
            If CalendarFrm.HelpLabel.Caption <> "" Then
                CalendarFrm.Height = 191 + CalendarFrm.HelpLabel.Height
            Else: CalendarFrm.Height = 191
                CalendarFrm.Show
            End If
        End If
    Next
End Sub
 
Upvote 0
Just checked it out and it works perfectly for the double click, Peter. Thanks a lot.

Have an amazing weekend. :)
 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,269
Members
452,628
Latest member
dd2

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