+ Reply to Thread
Results 1 to 3 of 3

Count the number of duplicates in a range and then create a ranked sort

  1. #1
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Count the number of duplicates in a range and then create a ranked sort

    Hi

    I have been scouring the web for info on this without success!

    I have a userform where users can input names of suppliers. As this list is built up, I want to have option buttons that have a caption name based on the most popular supplier name so that they can simply chose a supplier by clicking the appropriately named supplier. So, if after 10 entries, supplier "Smith" has been inserted 6 times and supplier "Jones" inputted 2 times and two other suppliers have been inputted once, I would like to have OptionButton1.Caption="Smith" and OptionButton2.Caption="Jones" created on the userform.

    This requires code for counting duplicates and ranking the result. I can't seem to get started on this!! Can anybody provide any guidance/help?

    Cheers

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Count the number of duplicates in a range and then create a ranked sort

    Hi newbi004

    I'd be looking for an easier way to do this problem. Find attached a solution that I think you think you want. You will need a Dynamic Named Range of the list of names. I've used a Pivot Table to get the most frequent in cells C4 and C5. The Pivot Table data is taken from the DNR. I've also put an Event macro behind the sheet to update the Pivot Table with each new name that is entered or changed. Then code behind the Userform to update/change the captions to what is in C4 and C5.

    See if you want to do all this for simply putting the two most frequent names in the Captions of two command buttons.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    07-23-2012
    Location
    London, England
    MS-Off Ver
    Excel 2007
    Posts
    211

    Re: Count the number of duplicates in a range and then create a ranked sort

    Wow! MarvinP...this is just what I was looking for! Thanks very much.

    I think it will be worth the effort as my users are not too computer literate and would much prefer to use click buttons rather than typing names all the time. My next problem will be to make sure that they spell the names consistently and correctly rather than "Smith", "smith", "Smitgh" etc!!!

    Thanks once again for your help.

+ 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