Consulting

Results 1 to 5 of 5

Thread: named range cell counting for calendar miss counting december

  1. #1
    VBAX Expert mperrah's Avatar
    Joined
    Mar 2005
    Posts
    744
    Location

    named range cell counting for calendar miss counting december

    Counting Cells in Calendar SamT.xlsm
    I have this calendar thanks to SamT.
    It counts the cells to fill in day of the month numbers in worksheet change using several functions (very elegant)
    For some reason it stops on the 12th day for december.
    I tried different years and they all stop on the 12th
    The other months of the year work perfectly to the end date for each month.
    Kinda stumped.
    thank you for any help.

    -mark

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Function EOM(dDate As Date) As Date
    dDate = Format(dDate, "d-m-yyyy")
    EOM = DateAdd("d", -1, DateValue(Month(dDate) + 1 & "-1-" & Year(dDate)))
    End Function
    Thank you for thoroughly testing that function for me. I wrote it years ago but didn't need it until now.
    Last edited by SamT; 09-11-2015 at 09:50 PM. Reason: Update Function
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    SamT, trying out your function as-is (I'm in the UK where it's d/m/y) for today (27th Aug 2015) with:
    Debug.Print Format(EOM(Date), "d mmm yy")
    I got:
    8 Jan 15

    Not sure whether I'm doing as I should, however there is a worksheet function (not EOM which is not available to VBA) EoMonth which you might use; it takes the date you supply and another argument being the number of months before/after your supplied date, in this case:
    Application.EoMonth(YourSuppliedDate, 0)
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    p45cal,

    EoMonth does not seem to be available in Excel 2003.

    Try adjusting the Format in EOM to "mmm/dd/yyyy".

    Thanks
    Last edited by SamT; 08-27-2015 at 11:25 AM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Expert mperrah's Avatar
    Joined
    Mar 2005
    Posts
    744
    Location
    Nailed it, out of the park.

    Thank you, SamTerrific

    -mark

Posting Permissions

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