+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : count number of times end of month is passed

  1. #1
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    count number of times end of month is passed

    Hi Guys,

    I have a formula which count the number of times the last day in the month is past within a date range. But it is not working as i would expect and would appreciate your help ...

    I have a date range as follows
    F4 = Start date in range
    G4 = End Date in range

    My buggy code looks like this at the mo :
    Please Login or Register  to view this content.
    Example of how i need this to count :
    F4 = 24/11/2011
    G4 = 26/01/2012

    And i need this to return a count of 2 ( as 31/11/11 and 31/12/11 are passed within the date range )

    Currently my code is returning 3 ??

    If the end date in the range is the last day of the month i need to count that too ...

    Any idea where im going wrong ?

    Thanks,
    Saz

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: count number of times end of month is passed

    Maybe: =DATEDIF(F4,G4,"m")+(G4=EOMONTH(G4,0))

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: count number of times end of month is passed

    Actually don't think that's right.

    Try: =(MONTH(G4)-MONTH(F4))+((YEAR(G4)-YEAR(F4))*12)+(G4=EOMONTH(G4,0))

    Dom

  4. #4
    Registered User
    Join Date
    02-20-2011
    Location
    Dublin
    MS-Off Ver
    Excel 2007
    Posts
    88

    Re: count number of times end of month is passed

    In the few examples i have just tried this works perfectly thanks a mill

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: count number of times end of month is passed

    This formula should also give you the correct result

    =DATEDIF(F4-DAY(F4)+1,G4+1,"m")
    Audere est facere

+ 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