+ Reply to Thread
Results 1 to 5 of 5

Thread: Counting years

  1. #1
    Registered User
    Join Date
    09-25-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Counting years

    I have a column of dates entered in the format dd/mm/yyyy.
    I want to count how many times a certain year occurs.
    I have knowledge of formulas but not of writing vb code.

  2. #2
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    9,506

    Re: Counting years

    Hello tracey

    If your dates are in A2:A100 and you have the year to count in C2, e.g. 2008, then use this formula in D2

    =SUMPRODUCT((YEAR(A$2:A$100)=C2)+0)

    copy down for more years listed in C3, C4 etc.

  3. #3
    Registered User
    Join Date
    09-25-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Smile Re: Counting years

    Fantastic!
    Works like a dream

    Thanks

  4. #4
    Registered User
    Join Date
    09-25-2009
    Location
    Birmingham, England
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Counting years

    I now have two columns:

    One in date format (dd/mm/yyyy)
    One in text format for systems (eg D3100CTW, D3300FTW etc)

    I need to count, for example, how many D3100 systems were made in 2008
    I can do this seperately but trying to put the two together just gives me a #value error
    I've tried AND and COUNTIFS functions but still get the same error
    The target cell is formatted as general

  5. #5
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    9,506

    Re: Counting years

    COUNTIFS function is only available in Excel 2007. If you have that version then you could accomplish it with COUNTIFS but you can't check for the year in the same way so it would be a little like this

    =COUNTIFS(A$2:A$100,">="&DATE(C2,1,1),A$2:A$100,"<="&DATE(C2,12,31),B$2:B$100,D2&"*")

    where A2:A100 contains dates, B2:B100 contains the system data, C2 is a specific year like 2008 and D2 is system type e.g. D3100

    To do the same in any version of excel you can extend the SUMPRODUCT formula like this

    =SUMPRODUCT((YEAR(A$2:A$100)=C2)*(LEFT(B$2:B$100,LEN(D2))=D2))

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0