+ Reply to Thread
Results 1 to 10 of 10

Calendar Macro

  1. #1
    Registered User
    Join Date
    05-23-2007
    Posts
    41

    Calendar Macro

    I have the following Calendar Macro. I want this to pop up when cell A5 is active vs assigning a Macro Button. How do I do? Thanks

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 09-19-2007 at 11:12 AM.

  2. #2
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641
    Hi Andrew,

    You can use the following code in the VBA module of the worksheet which contains the cell from which you want to trigger the routine:

    Please Login or Register  to view this content.
    The check of "Target.Cells.Count = 1" just ensures that the routine won't be triggered if the user selects a multi-cell range which includes cell A5.

    Hope this helps - please let me know how you get on.

    Best regards,

    Greg M

  3. #3
    Registered User
    Join Date
    05-23-2007
    Posts
    41
    I am confused... What is the full code to show calendar pop up when cell "A5" is selected?

    Thanks

  4. #4
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641
    Hi again,

    Excel triggers the "Worksheet_SelectionChange" event whenever a cell or range of cells is selected.

    The "If" statement first checks that only a single cell is selected, and then checks that there is a valid intersection between the selected cell ("Target") and cell A5 ("strCalendarCell") - in this case, a "valid intersection" means that the selected cell and cell A5 are one and the same.

    When the "If" statement returns a value of TRUE, the "frmCalendar.Show" statement is executed.

    Regards,

    Greg M

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Quote Originally Posted by andrew8008
    I am confused... What is the full code to show calendar pop up when cell "A5" is selected?

    Thanks
    Have you tried the code?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    05-23-2007
    Posts
    41
    I tried the code and it doesn't seem to work. Please check attached file.

    I would also like to activate when "B5" is active along with "A5".

    Thanks for all your help!!!
    Attached Files Attached Files

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,641
    Hi again,

    You entered the code in a standard VBA module - you must enter it in the VBA module for the WORKSHEET. Right-click on the worksheet tab & select "View Code" - this will display the VBA module for the worksheet.

    To extend the "activation range" use:

    Please Login or Register  to view this content.
    Regards,

    Greg M

  8. #8
    Registered User
    Join Date
    05-23-2007
    Posts
    41
    It isn't working... Attached is actual file. I need it to activate in cell C7 & G7.

    I get an error no matter what cell I click on. Thanks
    Attached Files Attached Files

  9. #9
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    It would work if you had a frmCalendar!

  10. #10
    Forum Expert
    Join Date
    11-23-2005
    Location
    Rome
    MS-Off Ver
    Ms Office 2016
    Posts
    1,628
    In attached file i added a form and a calendar control in the form (to select a date use double click).

    I hope it's what you need.

    Regards,
    Antonio
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1