+ Reply to Thread
Results 1 to 8 of 8

vba to sort by frequency

  1. #1
    Registered User
    Join Date
    02-20-2017
    Location
    des moines, iowa
    MS-Off Ver
    excel 2013
    Posts
    27

    vba to sort by frequency

    Hello all,
    I'm hoping there is a simple solution to this that I am not seeing..
    I have a table of part numbers and their data. the part numbers belong to design lines, (like a style family?) which are in column P i believe
    I would LOVE to sort the data based on the frequency of the line(the line with the most part numbers then the second most and so on).

    I unfortunately don't have an example of the codes I have tried as they are on a different computer, but i have attached an example spreadsheet to better show what i am trying to accomplish.
    I hope i made sense, and thanks much in advance!!
    Attached Files Attached Files

  2. #2
    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: vba to sort by frequency

    P
    Q
    R
    3
    Design
    4
    AG49H
    1
    Q4: =COUNTIF($P$4:$P$11, P4)
    5
    AG49M
    5
    6
    AG49M
    5
    7
    Multi Trac C/S
    2
    8
    AG49M
    5
    9
    AG49M
    5
    10
    AG49M
    5
    11
    Multi Trac C/S
    2


    Sort by that column.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    02-20-2017
    Location
    des moines, iowa
    MS-Off Ver
    excel 2013
    Posts
    27

    Re: vba to sort by frequency

    shg, thanks for the reply

    I'm actually trying to attach a macro to a command button.. and it looks as though you gave me a formula. i trying to modify it in vba, but i either get all 0's or it just counts all the cells and give me a total number every time..
    Please Login or Register  to view this content.
    any suggestions?

  4. #4
    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: vba to sort by frequency

    CountIf, not CountA

  5. #5
    Registered User
    Join Date
    02-20-2017
    Location
    des moines, iowa
    MS-Off Ver
    excel 2013
    Posts
    27

    Re: vba to sort by frequency

    i tried that as well... i just get all 0's

  6. #6
    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: vba to sort by frequency

    Can you insert the formula manually and get the correct results?

    Have you tried recording a macro?

  7. #7
    Registered User
    Join Date
    02-20-2017
    Location
    des moines, iowa
    MS-Off Ver
    excel 2013
    Posts
    27

    Re: vba to sort by frequency

    I hadn't even thought of recording one lol.... that worked perfectly thanks!

  8. #8
    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: vba to sort by frequency

    Good job, you're welcome.

+ 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. Sort by Highest Frequency
    By britth in forum Excel General
    Replies: 2
    Last Post: 07-28-2012, 04:49 AM
  2. [SOLVED] Sort by the Frequency
    By niko79542 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2012, 03:24 PM
  3. [SOLVED] Sort a row by the frequency of the numbers
    By niko79542 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2012, 01:39 PM
  4. Sort by frequency in a column
    By Lifeseeker in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2011, 06:07 PM
  5. Sort by frequency of occurrence
    By Lifeseeker in forum Excel General
    Replies: 2
    Last Post: 11-02-2011, 05:54 PM
  6. Sort by frequency?
    By Test5000 in forum Excel General
    Replies: 6
    Last Post: 04-09-2011, 02:47 PM
  7. [SOLVED] Is there a way to sort text by frequency within Excel?
    By jellis1919 in forum Excel General
    Replies: 1
    Last Post: 08-11-2005, 09:05 PM
  8. Sort Data by Frequency
    By Susan Smith in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-25-2005, 01:06 AM

Tags for this Thread

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