+ Reply to Thread
Results 1 to 27 of 27

Finding more than one occurrence

  1. #1
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Finding more than one occurrence

    I have attached a mockup of the below requirement. I hope someone can assist!

    I need to be notified (in column G and H) when there is a second and third occurrence of the same team (located in row J and K). A notification of the value 2 for the second occurrence, 3 for the third.

    The following condition must also be met, i.e. values in rows of columns B,C,D,E,F must be equal.

    In the mockup you will see that all values from B5-F5 down to B18-F18 are equal. So, within this range, you can check from J5-J18 and K5-K18 how many times a team exists. You need to check both J and K for the same team and must start at J5-J18 followed by K5-K18.

    For example J5 = Reading. By checking J5-J18 Reading only exists once. But checking also K5-K18, you will find Reading in K18. So, I would like you to place a 2 in H18. Same applies for other teams in J and K. Any second, third, fourth occurrence found “in” column J should have the notification in column G on the row the occurrence was found. Any second, third, fourth occurrence found “in” column K should have the notification in column H on the row the occurrence was found.

    Note I used fill colour in the mockup to highlight the some examples. Colour is not a requirement.
    Also note that the real excel I need to run this in has close to 700k rows of data.

    Thank you
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,890

    Re: Finding more than one occurrence

    Try this in G2 and copied down and across.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  3. #3
    Forum Expert
    Join Date
    06-05-2017
    Location
    Brazil
    MS-Off Ver
    Microsoft 365 Version 2412
    Posts
    1,508

    Re: Finding more than one occurrence

    Edited.

    I realized I was not taking both columns J & K at once.
    Last edited by Estevaoba; 11-11-2023 at 09:35 PM.

  4. #4
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,935

    Re: Finding more than one occurrence

    G2:
    Please Login or Register  to view this content.
    h2:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Ben Van Johnson

  5. #5
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Finding more than one occurrence

    Please try in G2 and copy down and to the right:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Quote Originally Posted by protonLeah View Post
    G2:
    Please Login or Register  to view this content.
    h2:
    Please Login or Register  to view this content.
    Thanks Ben, works well apart from one part. It doesn't seem to consider always the condition "B,C,D,E,F must be equal".
    For example, in the range B19-F19 down to B21-F21 there is one difference in E20 but it still placed a '2' in G20.

  7. #7
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Quote Originally Posted by HansDouwe View Post
    Please try in G2 and copy down and to the right:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks Hans. It doesn't seem to consider always the condition "B,C,D,E,F must be equal".
    For example,there is a '2' in G19 for Chester but D16 and E16 are different to D19 and E19

  8. #8
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Quote Originally Posted by windknife View Post
    Try this in G2 and copied down and across.

    Please Login or Register  to view this content.
    It hasn't found the 2 that should be in G4 and the 3 that should be in G14

  9. #9
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,890

    Re: Finding more than one occurrence

    Amended formula in G2 copied down and across.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114
    Dearly appreciated.. I will try it in the big sheet that i have and let you know if i come across something that doesn't match. Thanks again

  11. #11
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Quote Originally Posted by windknife View Post
    Amended formula in G2 copied down and across.

    Please Login or Register  to view this content.
    The formula seems to work but I am having extreme difficulties running it on my sheet (800,000 rows). I have tried running it on smaller chunks of 20k-50k rows but still not much success.
    I notice that it keeps a lookup of all columns from B to F even once it has processed them. This is what's maybe causing the delay?
    These groups of information (i.e. same info in B to F) only appear once in blocks of usually 10 rows and a max of 50 rows. So, if they are processed there is no need to keep looking for them. I also have my sheet sorted by B to F to make sure they don't appear elsewhere.
    Is it possible the formula can be modified to take this into account so that it doesn't keep a stranglehold on the entire sheet?

  12. #12
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,890

    Re: Finding more than one occurrence

    Perhaps, you must use VBA to solve it for big data.

  13. #13
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Unfortunately, I have no idea about VBA and coding.

  14. #14
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,890

    Re: Finding more than one occurrence

    How about this with a helper column?

    G2
    =B2&C2&D2&E2&F2

    H2
    =IF($B2="","",IFERROR(1/(1/(COUNTIFS($G$1:G1,G2,$K$1:K1,K2)+COUNTIFS($G$1:G1,G2,$L$1:L1,K2)))+1,""))

    I2
    =IF($B2="","",IFERROR(1/(1/(COUNTIFS($G$1:G1,G2,$K$1:K1,K2)+COUNTIFS($G$1:G1,G2,$L$1:L1,K2)))+1,""))

    copied down.
    Attached Files Attached Files

  15. #15
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    @windknife - seems to be working brilliantly. I will finish it all off and check it and close the thread.
    Brilliant thinking on your behalf! Wish I could give you more credit for this but I gotta spread the love around.
    Last edited by John Sio; 11-26-2023 at 09:53 AM.

  16. #16
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,645

    Re: Finding more than one occurrence

    Do not employ helper column, but not sure it is OK for, 800000 rows, but try:

    G3:
    Please Login or Register  to view this content.
    copy to H3 and down
    Attached Files Attached Files
    Quang PT

  17. #17
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Quote Originally Posted by windknife View Post
    How about this with a helper column?

    G2
    =B2&C2&D2&E2&F2

    H2
    =IF($B2="","",IFERROR(1/(1/(COUNTIFS($G$1:G1,G2,$K$1:K1,K2)+COUNTIFS($G$1:G1,G2,$L$1:L1,K2)))+1,""))

    I2
    =IF($B2="","",IFERROR(1/(1/(COUNTIFS($G$1:G1,G2,$K$1:K1,K2)+COUNTIFS($G$1:G1,G2,$L$1:L1,K2)))+1,""))

    copied down.
    @windknife
    I ran your formulas and indeed they were extremely quick for large volumes of data.
    However, I can't understand why I have incorrect results now compared to the initial mockup where the results were correct.
    I have attached an example and can't understand why there is a date in H21 instead of a '2' and why there is a '2' in I21 instead of null.
    Can you please take a look? Thanks John
    Attached Files Attached Files

  18. #18
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,890

    Re: Finding more than one occurrence

    I have attached an example and can't understand why there is a date in H21 instead of a '2' and why there is a '2' in I21 instead of null.
    1. H column's format is date, change it to Number.
    2. I type wrong formula in I2.

    I2
    =IF($B2="","",IFERROR(1/(1/(COUNTIFS($G$1:G1,G2,$K$1:K1,L2)+COUNTIFS($G$1:G1,G2,$L$1:L1,L2)))+1,""))
    Attached Files Attached Files

  19. #19
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    @windknife thank you, at the end of the day I had to create 8 different excel sheets, with 100k per sheet in order for it to complete successfully.
    Just wondering if you have any good ideas about how I can keep the values instead of the formulas in G, H and I?
    I have tried copy / paste special / values but it takes an eternity.
    Let me know if there is a quicker way to do it please.
    Thanks, John

  20. #20
    Forum Expert
    Join Date
    04-14-2009
    Location
    Taiwan
    MS-Off Ver
    Excel 2016,2019,O365
    Posts
    2,890

    Re: Finding more than one occurrence

    How about use Hot-Key ?

    1. Ctrl+V (Copy the cells)
    2. Shift+F10
    3. V (Paste as Values)

  21. #21
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    @windknife
    No unfortunately same result. If you come across something else, pls let me know.

  22. #22
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,731

    Re: Finding more than one occurrence

    Only VBA if want to avoid "key" actions as you have to select the cells for copy/paste.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  23. #23
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Ok, thanks John

  24. #24
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,731

    Re: Finding more than one occurrence

    You can copy/paste whole column rather individual cells so not too onerous!

  25. #25
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114

    Re: Finding more than one occurrence

    Yes, i have done that but it brings the computer to a standstill.
    So, with VBA, I would need someone to write the code for me and then I run it via a macro?

  26. #26
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,731

    Re: Finding more than one occurrence

    Try .. converts columns H:I to values

    Please Login or Register  to view this content.
    Select a sheet and run the macro. Repeat for all sheets.

    Ensure you have a COPY of your "master" file!
    Last edited by JohnTopley; 12-12-2023 at 04:25 PM.

  27. #27
    Forum Contributor
    Join Date
    07-26-2013
    Location
    Athens, Greece (born and raised in Sydney, Australia)
    MS-Off Ver
    Excel 2010
    Posts
    114
    @JohnTopley
    Once again Mr Topley to the rescue. I will try it out John and take all your instructions into consideration. Will let you know the outcome. Thanks

+ 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. Finding 1st Occurrence
    By drltr6 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-08-2022, 04:25 PM
  2. [SOLVED] Finding the nth occurrence after a specified position
    By Subtle in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 08-08-2017, 07:05 AM
  3. [SOLVED] Finding last occurrence of value in row range
    By Gti182 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 05-19-2017, 10:28 AM
  4. [SOLVED] Finding last occurrence and summing up everything above it.
    By rdperry11 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-23-2015, 05:29 AM
  5. Finding second occurrence is not working
    By allanpark in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-06-2014, 02:39 PM
  6. Finding second occurrence. HELP!
    By allanpark in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-05-2014, 09:50 PM
  7. [SOLVED] Finding the last occurrence of a value in a list
    By _Josh_ in forum Excel General
    Replies: 9
    Last Post: 11-09-2012, 09:23 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