+ Reply to Thread
Results 1 to 3 of 3

Help with VB code or Formula to calculate the unique occurrences during a month

  1. #1
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Help with VB code or Formula to calculate the unique occurrences during a month

    I have a worksheet with the following sample data
    Day Id
    1 22
    1 22
    1 33
    1 44
    1 44
    2 22
    2 33
    2 44

    What I am trying to do to count unique number of times each Id appears per day.

    So in table above I need to derive the following result
    Day 1 No of Unique Ids = 3
    Day 2 No of Unique Ids = 3

    Total number if unique id for all the days = 6

    Is there a easy formula or VB code which can give me the above. Basically to find a total of Unique Ids for all the days. I have a file which has over 10000 rows.

    Thanks in advance

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Help with VB code or Formula to calculate the unique occurrences during a month

    Hi,

    Assuming your example is contained within A1:B9 including headers, the following array will give you the number of unique entries for day 1 and 2 respectively.

    =SUM(--(FREQUENCY(IF(A2:A9=1,B2:B9),B2:B9)>0))
    =SUM(--(FREQUENCY(IF(A2:A9=2,B2:B9),B2:B9)>0))

    Note that CTRL, SHIFT and ENTER is required to confirm an array formula.
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Contributor
    Join Date
    06-17-2014
    Location
    london
    MS-Off Ver
    365
    Posts
    398

    Re: Help with VB code or Formula to calculate the unique occurrences during a month

    This worked perfectly. Tank you so much

+ 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. [SOLVED] Formula to Calculate Occurrences of Staff Absence
    By Steve Bowden-Jones in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 08-10-2020, 11:48 AM
  2. [SOLVED] VBA or Excel code to calculate the % of a unique value and how often it occurs
    By zainycmt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-14-2016, 05:31 AM
  3. Formula that counts the number of unique occurrences in the ID field?
    By soupi in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 12-08-2015, 06:24 PM
  4. Need Formula to Calculate Sale Month Back to Production Month
    By Newbie403 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 04-13-2015, 05:28 PM
  5. vba code needed to calculate the number of working days thus far for the month
    By Jim885 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-22-2014, 09:38 PM
  6. VBA Code help to count no. of occurrences per month
    By soph33 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-01-2009, 02:17 PM
  7. Unique occurrences
    By cheaperThanAPro in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-31-2008, 08:40 AM

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