+ Reply to Thread
Results 1 to 8 of 8

Sort by a column dependent on header value

  1. #1
    Registered User
    Join Date
    10-26-2016
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    4

    Sort by a column dependent on header value

    I have a price list that could contain anywhere from 1 price, to up to 6 prices, based on volumes.

    The program we are extracting the data from puts a header in each column with a sucessively increasing number (Price Vol #1, Price Vol #2, Price Vol #3).

    I need the macro to search through these column headers, find the highest number in the header, (from example above "3") and then sort that column from lowest to highest.

    I have attached a piece of my sample data (PricingList.Raw) that I need to sort. I first need to sort by part number, then by the highest price volume.

    I have also attached a copy of what the data should look like (PricingList.Final). Which I manually sorted by Part number (Column A) and then Price Volume #4 (Column I).
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Sort by a column dependant on header value

    It looks like the highest number in the header will always be the last used column. Is this true?
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Registered User
    Join Date
    10-26-2016
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Sort by a column dependant on header value

    Yes. That is true.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Sort by a column dependent on header value

    Try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    10-26-2016
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Sort by a column dependent on header value

    I stand corrected, the column I wish to sort by will never be the last column used. It is embedded within a larger table of data, I just extracted the four columns of pricing for an example.

    See attached for actual data that will be used. It is extracted from our program as a .cvs file and then saved as an excel file once formatting is complete.

    The columns the pricing is located in are columns P, X, AF and AN.

    In this example, I would like to look at all the headers, identify which column header has the highest value (#4) and then sort by that column.
    Attached Files Attached Files

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Sort by a column dependent on header value

    Try:
    Please Login or Register  to view this content.
    Re-save the file as a macro-enabled Excel workbook so its extension changes to "xlsm".

  7. #7
    Registered User
    Join Date
    10-26-2016
    Location
    Ohio
    MS-Off Ver
    Office 2010
    Posts
    4

    Re: Sort by a column dependent on header value

    That worked! Thank you very much!

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,821

    Re: Sort by a column dependent on header value

    You are very 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 Select Range: Either Find Column Header or Last Column:Last Row
    By mbryson in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-02-2014, 08:03 AM
  2. How to Sort Columns by Clicking on Column Header
    By hwhip in forum Excel General
    Replies: 4
    Last Post: 03-05-2014, 01:02 PM
  3. Sort column list by header
    By suprchic66 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-03-2014, 11:06 PM
  4. [SOLVED] Sort by column E, and create sheets named by that column, add header and data
    By salaso69 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-24-2012, 12:42 AM
  5. [SOLVED] Sort, placing rows with 0 in the dependent column last
    By am462 in forum Excel General
    Replies: 5
    Last Post: 11-10-2012, 01:49 PM
  6. Replies: 3
    Last Post: 05-17-2009, 04:31 AM
  7. sort column header
    By marathon runner in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-26-2006, 10:15 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