+ Reply to Thread
Results 1 to 25 of 25

Find and lists the 1st 2nd 3rd or nth most repeating number in a range

  1. #1
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    I found an array formula that allows me to determine and list the 1st, 2nd, 3rd, etc most repeating number in a range, a column in this case.

    All I have to do is set in place the array formula on the first cell where I want the result and then drag down and it will automatically auto adjust to find the next consecutive most repeating number in the range.

    However, the result given is not true at all.

    The actual first most frequent number in the range is 2037, it repeats 70 times.

    But the array formula picks 2038 as the first most repeating number, but it only repeats 66 times – four times less than the other number 2037. Obviously, something is wrong with the formula and I can’t figure out what.

    The actual second most repeating number is 2034, it repeats 68 times. The actual third most repeating number is 2031, it repeats 67 times. But the array formula in place does not find these numbers at all.

    I’m doing it this way (with an array formula) to avoid using VBA or a helper column.

    In the attached file, column G (in dark gray) is where I need the results, where the array formula is in place. All the other columns and formulas are working fine.

    Please help.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    You can visualize it using Conditional formatting to show the top 10
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    would the below work for you ?

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    That won't work because there are too many and LARGE is not an option
    See attached file

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Yep, it works !!!
    Re-attached my file with the new formula
    Hope Luis is happy

  6. #6
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    I am bit confused by posts #4 & #5 -- the 2nd attachment (#5) is just the formula provided in post #3 -- not sure why this needed to be re-posted ?

    the formula in post#3 converts the "frequency" # to millions and adds the associated value -- so most frequent is largest, but each value is unique
    the AGGREGATE (w/large) will return the largest values from 1 to n
    the outers MOD then strips out the value of interest (i.e. removes the frequency)

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Okay, I just pasted it in my answer and updated the file.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Since this is the VBA-subforum just for fun.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    The formula provided by XLent (post #3) and used in the file by Keebellah (post #5, after updating his file) works perfectly.

    Yes, Keebellah, I'm super happy !!!

    bakerman2, I do love VBA too! Can you please implement it in the file, please please? and attach it?

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Done.

    Happy to assist.
    Attached Files Attached Files
    Last edited by bakerman2; 09-11-2021 at 05:10 PM.

  11. #11
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    bakerman2,

    Thank you. Works great.

    Because it does not use any helper column (it's leaner), I'll be using the VBA solution.

    If any one can find the way to use a formula (or array formula) that does not need any helper column, please let me know.

    Everyone, have a very blessed day.
    Last edited by Luisftv; 09-11-2021 at 09:03 PM.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Post #5 with XLent's formula does not ned the helper column, if you read Bakerman2 remark he just did the VBA for fun

  13. #13
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    The same file, as @bakerman2 but no macros and a little conditional formatting and no helper columns and thanks to @XLent's formula
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    You are absolutely right Keebellah, my mistake.

    I opened the file you provided in post #5 (your adaptation of XLent code) and I saw some helper columns and unintentionally took it for what was needed in for column G. I just opened it and erased all those helper columns and noticed that your adaptation in column G works flawlessly.

    So this is awesome!!!

    Again, I apologize for not noticing sooner. I just pulled a non-stop day at work without taking a lunch break, I'm not excusing myself but it's true I got distracted. Sorry.

    Thank you both again. I not only got the formula I was needing but also VBA code which I love using too.

    Oh, I just opened that last file you sent and it's flawless. I like those little flags!!!

    Have a wonderful day and thank you again, and thanks again to XLent, and bakerman2 for the VBA code. I'm very grateful for having both options.

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    All the credit goes to @XLent for the formula, I'm no good at those things, my 'speciality' is VBA but I enjoy tweaking and playing around with whatever comes up in Excel files
    Have a nice day too and ... Happy coding

  16. #16
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Quote Originally Posted by bakerman2 View Post
    Since this is the VBA-subforum just for fun.

    Please Login or Register  to view this content.
    You do not actually have to test if the dictionary item exist in order to add it... the dictionary object will automatically add it if it doesn't exist. Given that, your If..Then..Else..EndIf block can be reduced to this single line of code...
    Please Login or Register  to view this content.

  17. #17
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Rick Rothstein,

    Could you please provide the complete code, perhaps I did something wrong at my end.

    With the code suggested by XLent, I get 57 repeating numbers, which is correct. When trying to shrink the code as you suggested I only get 20 repeating numbers and they are all wrong. I'm sure I did something wrong.

    Thanks.


    Never mind. I found my typo. Your suggestion works. Thank you so much.
    Last edited by Luisftv; 09-12-2021 at 03:49 AM.

  18. #18
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Quote Originally Posted by Luisftv View Post
    Rick Rothstein,

    Could you please provide the complete code...

    With the code suggested by XLent
    In which message did XLent post VBA code?

  19. #19
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    bakerman2 provided the code in post #8.

    But never mind, I found my typo. Here it is the bakerman2 code with your sugestion:

    Please Login or Register  to view this content.
    Thanks for the suggestion.
    Last edited by Luisftv; 09-12-2021 at 04:12 AM.

  20. #20
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,410

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Quote Originally Posted by Luisftv View Post
    XLent provided the code in post #8.
    It was bakerman2 who provided the code in Message #8 (and that is who I replied to with my suggestion).

  21. #21
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Yes, you are right. Apologies bakerman2. I corrected the mistake in that post.

    Thank you so much again.

  22. #22
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    FWIW, for robustness, I would modify the formula, (per red):

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  23. #23
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,905
    Quote Originally Posted by Rick Rothstein View Post
    In which message did XLent post VBA code?
    XLent did NOT post any code, just a formula

  24. #24
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    Yes Keebellah, you are correct, and that has been noted and corrected as well. The VBA code was given by bakerman2. XLent gave the formula.

  25. #25
    Forum Contributor
    Join Date
    11-17-2018
    Location
    Los Angeles
    MS-Off Ver
    Office 2010
    Posts
    208

    Re: Find and lists the 1st 2nd 3rd or nth most repeating number in a range

    XLent,

    The formula you provided in post #22 works flawlessly (yes, I removed the blank spaces as you noted). Thanks once more.

+ 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] Find repeating patterns in a range of data
    By remigh in forum Excel Formulas & Functions
    Replies: 17
    Last Post: 06-20-2018, 09:48 AM
  2. Find the five most repeating number w/ criteria?
    By profector in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-16-2008, 06:08 PM
  3. How do I check repeating sets of number in a range
    By Tshidiso in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-07-2005, 12:05 AM
  4. How do I check repeating sets of number in a range
    By Tshidiso in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 PM
  5. How do I check repeating sets of number in a range
    By Tshidiso in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  6. [SOLVED] How do I check repeating sets of number in a range
    By KL in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2005, 11:05 AM
  7. [SOLVED] How do I check repeating sets of number in a range
    By Tshidiso in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 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