+ Reply to Thread
Results 1 to 15 of 15

VB Calendar Macro to highlight current date

  1. #1
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26

    VB Calendar Macro to highlight current date

    I have a macro that displays a calendar with code to highlight the current date, but this part of the code does not work and the current date is not highlighted.

    Please Login or Register  to view this content.
    Suggestions?

    Thanks,
    jlcford
    Last edited by jlcford; 10-10-2008 at 02:00 PM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What format is the inputbox expecting because it won't accept any variation of dates that I have tried.
    Hope that helps.

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

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26
    I sorry I don't quite understand your question. I start out with a blank worksheet. I run the macro and type in the month and year of the calendar month I want to display. The Month and Year are displayed along with the dates 1 - 30 or 31 in cells C7:AM7 depending on what day of the week the month begins with.

    jlcford

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    When the prompt for month & year comes up, what do you type in. I have tried 12/2008 and December 2008 and Dec 2008, all bring up the error message

  5. #5
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26
    "October 2008"

    That is how the program is written. It only accepts that type of input.

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Your Conditional Formatting can't work, the cells do not contain a date

  7. #7
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26
    Any suggestions on how to get them to show a date?

    jlcford

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Try this
    Please Login or Register  to view this content.
    Last edited by royUK; 10-09-2008 at 05:52 AM.

  9. #9
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26
    I get a runtime error with this line of code.

    Please Login or Register  to view this content.
    The problem with using the reference DAY() (I have tried this before), is if I am looking in another calendar not the current month it highlights the "interger" of the current Day whether it is in the current month or not.

    There has to be a way to write the code to populate the calendar days so they can be recognized as TODAY() - I am just haven't been able to figure it out.

    jlcford

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This works fine for me

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26
    Sorry for the delay in my response. I was out of the office yesterday. Yes, you are correct this code works perfectly. Thanks for the help.

    jlcford

  12. #12
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Glad it worked for you

  13. #13
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26

    Problem with highlighting dates preceding years

    When I began working on my calendar I ran into a problem in October 2009. It highlighted October 10, 2009. So I added the following to my code:
    Please Login or Register  to view this content.
    But then when I type in the Month and year in the InputBox, I get the error message from the on Error GoTo My Error Trap.

    So I assume the code I have added the syntax is wrong. Again any suggestions.

    Thanks,
    jlcford

  14. #14
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    I would not use the error trap whilst developing the code. It throws the message whatever error is generated.

    I think this does what you want

    Please Login or Register  to view this content.
    Last edited by royUK; 10-10-2008 at 12:50 PM.

  15. #15
    Registered User
    Join Date
    10-07-2008
    Location
    virginia
    Posts
    26

    Calendar with Highlighted Date now completely Functional

    Thanks again for your help. I have posted the calendar through December 2009 with no problems.

    jlcford

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. create macro to delete row with a date previous to current date
    By laserk7 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-25-2008, 12:36 PM
  2. Advanced Timesheet
    By DaKohlmeyer in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-28-2008, 04:49 PM
  3. Don't open the VB Editor when a macro is executed
    By rajusampathirao in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-21-2008, 06:55 AM
  4. macro for matching date and changing cell color and merging like cells
    By learning_excel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-12-2007, 06:10 PM

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