+ Reply to Thread
Results 1 to 35 of 35

Excel Formula to extract top 5 states from column.

  1. #1
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Excel Formula to extract top 5 states from column.

    I need help with an Excel formula.

    In Worksheet #1 I have roughly 800 state abbreviations listed. The column is M.

    I need to set a formula to pull the top five most occurring states and automatically place them in Worksheet #2 in cells A19:A23.

    I thank you in advance for your assistance!
    Last edited by KINNEY0201; 08-23-2010 at 09:53 AM.

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    Say you enter the most frequent occurence in C1 with formula:

    Please Login or Register  to view this content.
    adjust ranges to suit.

    then in C2 enter:

    Please Login or Register  to view this content.
    adjust ranges to suit and confirm this one with CTRL+SHIFT+ENTER not just ENTER and copy down
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by NBVC View Post
    Say you enter the most frequent occurence in C1 with formula:

    Please Login or Register  to view this content.
    adjust ranges to suit.

    then in C2 enter:

    Please Login or Register  to view this content.
    adjust ranges to suit and confirm this one with CTRL+SHIFT+ENTER not just ENTER and copy down
    The column M is in a different sheet. I tried adjusting, but ended up getting N/A as a result. Here was the formula:

    =INDEX('FA 08-20-10'!$M$2:$M$2000,MODE(MATCH('FA 08-20-10'!$M$2:$M$2000,'FA 08-20-10'!$M$2:$M$2000,0)))

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    Do you have blanks? Blanks not allowed.

  5. #5
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    If you have blanks at bottom of list and you want it to be a bit dynamic..

    In an empty cell, say D2 enter formula: =MATCH(REPT("z",255),M:M)

    then replace formula in C2 with:

    Please Login or Register  to view this content.
    and formula in C3 with:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER and copied down.

  6. #6
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    I'm sorry but I don't follow. There are blanks throughout, just not at the bottom. The original spreadsheet needs to stay intact and unsorted. Isn't this possible. And as far as cell references. I need the 5 top results to be located in cells A20:A24.

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    Ok,

    Go to Formulas menu and click Define Name from the Defined Names section

    Enter LastRow in the Name field and enter formula: =MATCH(REPT("z",255),$M:$M) in the Refers to field.

    Then in A20 enter formula:

    Please Login or Register  to view this content.
    confirm it now with CTRL+SHIFT+ENTER

    in A21 enter formula:

    Please Login or Register  to view this content.
    and confirm with CTRL+SHIFT+ENTER and copy downwards to A24

  8. #8
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Which cell or location should I be when entering the "define cells"?

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    Doesn't matter.

  10. #10
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Did not work. Once I corrected formula to refer to sheet one, it returned the top state as "state" which is the heading of the column.

    =INDEX('FA 08-20-10'!M2:INDEX('FA 08-20-10'!M:M,$D$2),MODE(IF(ISNUMBER(MATCH('FA 08-20-10'!M2:INDEX('FA 08-20-10'!M:M,LastRow),'FA 08-20-10'!M2:INDEX('FA 08-20-10'!M:M,LastRow),0)),MATCH('FA 08-20-10'!M2:INDEX('FA 08-20-10'!M:M,LastRow),'FA 08-20-10'!M2:INDEX('FA 08-20-10'!M:M,LastRow),0))))
    Last edited by shg; 08-23-2010 at 01:03 PM. Reason: deleted quote

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    Possible to attach your workbook?

  12. #12
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by NBVC View Post
    Possible to attach your workbook?
    Unfortunatley not due to the content. Student information.

  13. #13
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by NBVC View Post
    Possible to attach your workbook?
    I was able to get the formula below to work perfectly to produce the #1 most common state, however, I am unable to figure out how to get the next four states below it. I tried copying down but it just repeated the same state. Any suggestions?

    =INDEX('FA 08-20-10'!M:M,MATCH(MAX(COUNTIF('FA 08-20-10'!M:M,'FA 08-20-10'!M:M)),COUNTIF('FA 08-20-10'!M:M,'FA 08-20-10'!M:M),0))

  14. #14
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    Did you adjust the Defined Name, LastRow's range to the other sheetname too?

    i.e. it should be: =Match(Rept("Z",255),'FA 08-20-10'!$M:$M)

  15. #15
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    With your suggested formula? Yes.

    Any idea on the last formula I listed? How to get it to list the next highest 4 states? At this point, it looks like the easiest route, but then again, I'm not the expert, that's why I'm here for help.
    Last edited by shg; 08-23-2010 at 07:41 PM. Reason: deleted spurious quote

  16. #16
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    See my sample (I think working) workbook, using your sheetname and the results are in Sheet1.

    See if you can find any differences with your workbook....
    Attached Files Attached Files

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

    Re: Excel Formula to extract top 5 states from column.

    Find an example of what you want attached.
    I did it in a few steps which keeps the formulas smaller.

    I hope this example will help you solve your problem.
    Attached Files Attached Files

  18. #18
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by NBVC View Post
    See my sample (I think working) workbook, using your sheetname and the results are in Sheet1.

    See if you can find any differences with your workbook....
    Wouldn't work. I removed the data from mine and left the needed columns and attached here. If you wouldn't mind, take a look at the formula that is already entered and see if we can work from that to bring the next 4 states into play.

    Thanks,
    Attached Files Attached Files

  19. #19
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    See the attached.

    I did not see any Defined name for LastRow
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Do the states not change when the main list changes? For example, I took out all of the IL to see what would happen, but Illinois still remained in the top 5????????
    Last edited by shg; 08-23-2010 at 07:40 PM. Reason: deleted spurious quote

  21. #21
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    It should not... I just deleted all the IL's and now my 5th item in the result list is CT.

    Did you, in fact delete all of the IL's?

    Also, go to the Formulas tab and in the Calculation Option drop down, make sure it has Automatic selected.

  22. #22
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by MarvinP View Post
    Find an example of what you want attached.
    I did it in a few steps which keeps the formulas smaller.

    I hope this example will help you solve your problem.
    Thanks for the example, however, I need to figure out a way to not use other columns for the formulas and enter the actual formulas into the 5 cells that will show the results.

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

    Re: Excel Formula to extract top 5 states from column.

    If you are allowed to make intermediate data the attached might be an easier answer.
    Those real long formulas make my head hurt so I try to do the problem in small steps.

    I guess I'm too old to follow a formula that goes to a second line.
    Attached Files Attached Files

  24. #24
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by NBVC View Post
    It should not... I just deleted all the IL's and now my 5th item in the result list is CT.

    Did you, in fact delete all of the IL's?

    Also, go to the Formulas tab and in the Calculation Option drop down, make sure it has Automatic selected.
    Yes, I deleted all IL's. And Calculation Option is already set to automatic. Any other possibilities?

  25. #25
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    No there aren't as far as I know...

    Are you in the same book I re-attached or are you in your original?

  26. #26
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by NBVC View Post
    See the attached.

    I did not see any Defined name for LastRow
    I tried copying your 5 cells with formulas into my original spreadsheet.

  27. #27
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    You made sure that they are not now referring to an outside workbook source?

    You have the proper formula in the Define Range "LastRow"?

    You reconfirmed each formula with CTRL+SHIFT+ENTER?

  28. #28
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Quote Originally Posted by NBVC View Post
    No there aren't as far as I know...

    Are you in the same book I re-attached or are you in your original?
    OK, I finally figured it out. All I had to do was make it reference my original spreadsheet and not yours.

    One more question........if I wanted to imbed an exception formula into the formulas you provided, where would they go. For example, I need to only count states of students who meet certain criteria. Specifically, they must meet all of the following:

    ('FA 08-20-10'!B:B="FTIC")

    ('FA 08-20-10'!B:B="TRANS")

    ('FA 08-20-10'!E:E="STU")

  29. #29
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    With these new conditions, the formulas are becoming a lot more inefficient.... Perhaps it might be wiser to invest in some helper columns to do some of the work and reduce the need for heavy array formulas...

    But, assuming you are indeed in XL2007, you can try these and see the affect.

    Please Login or Register  to view this content.
    AND

    Please Login or Register  to view this content.

  30. #30
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Tried the first........got "N/A". Do I need to use them both or something in order for it to work? Thanks in advance for your help.
    Last edited by shg; 08-23-2010 at 07:40 PM. Reason: deleted spurious quote

  31. #31
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Excel Formula to extract top 5 states from column.

    Alright, it probably isn't working.. the MATCH() parts in the formula are getting messed up..

    I really do think you need to add a couple of helper columns to get this achieved as efficiently as possible.

    What I suggest...

    in N2 (or free column in the FA 08-20-10 sheet enter:

    Please Login or Register  to view this content.
    copied down.

    in adjacent column, O2 (or free column) enter:

    Please Login or Register  to view this content.
    then in main sheet: in a free column in row 19, enter formula:

    Please Login or Register  to view this content.
    copied down 4 more cells.

    then in A19:

    Please Login or Register  to view this content.
    confirmed with CTRL+SHIFT+ENTER and copied down 4 more cells.

  32. #32
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    We will just keep trying to fix the match parts of the formula as we are trying to avoid helper columns. Thanks very much for your help, however, you got us real close!
    Last edited by NBVC; 08-23-2010 at 03:49 PM. Reason: Deleted quoting of whole post.

  33. #33
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Is it possible to fix the MATCH problem or any other way to do it? I cannot create any templates or add formulas to the FA 08-20-10 sheet because each week I will be dropping brand new data into it. I appreciate all of your help!
    Last edited by shg; 08-23-2010 at 07:39 PM. Reason: deleted spurious quote

  34. #34
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Excel Formula to extract top 5 states from column.

    Kinney, please stop quoting whole posts. It's just clutter.

    Use the REPLY button, not the QUOTE button.
    Entia non sunt multiplicanda sine necessitate

  35. #35
    Registered User
    Join Date
    10-05-2009
    Location
    Florida
    MS-Off Ver
    Excel 2007
    Posts
    76

    Re: Excel Formula to extract top 5 states from column.

    Sorry..........................

+ 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