+ Reply to Thread
Results 1 to 3 of 3

Excel 2007 : Sorting by specific data with cells

  1. #1
    Registered User
    Join Date
    09-28-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Sorting by specific data with cells

    Hi,
    I need to sort some data based on certain words with each cell. For ex)

    INCOME ON 1,129 POTLATCH DIV RATE
    INCOME ON 2,073 TOWER GRP
    INCOME ON 2,136 ADIMISTAFF INC DIV
    INCOME ON 15 POTLATCH DIV
    INCOME ON 6 TOWER GRP DIV

    I would like the following output:
    INCOME ON 1,129 POTLATCH DIV RATE
    INCOME ON 15 POTLATCH DIV
    INCOME ON 2,073 TOWER GRP
    INCOME ON 6 TOWER GRP DIV
    INCOME ON 2,136 ADIMISTAFF INC DIV

    So in other words, all the cells that contain "POTLATCH" are together, cells with "TOWER" are together, etc. (regardless of the rest of the details in that corresponding cell).

    Is this possible to do. It's currently being done manually and it takes too long.
    Thank you so much for your help.
    C

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Sorting by specific data with cells

    Assuming
    1) those text strings are in column A starting at A1
    2) column AA is empty
    3) the word to sort by is always the word after the third space in the text string

    ...this macro will do what you want:

    Please Login or Register  to view this content.

    How/Where to install the macro:

    1. Open up your workbook
    2. Get into VB Editor (Press Alt+F11)
    3. Insert a new module (Insert > Module)
    4. Copy and Paste in your code (given above)
    5. Get out of VBA (Press Alt+Q)
    6. Save as a macro-enabled workbook

    The macro is installed and ready to use. Press Alt-F8 and select it from the macro list.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Registered User
    Join Date
    09-28-2010
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2007
    Posts
    2

    Thumbs down Re: Sorting by specific data with cells

    Hi JBeaucaire,

    Thank you so much for the solution. I will try this tonight and let you know the results.

    Take care
    Chris

+ 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