+ Reply to Thread
Results 1 to 7 of 7

Sort row but keep adjacent cells tied to sort cell

  1. #1
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Sort row but keep adjacent cells tied to sort cell

    Hello,

    I am not even sure if it is possible but it will save me alot of work if it is.

    I am trying to sort a row in ascending order but i need to only sort the cells contaning numbers and keep the adjacent cells containg text on either side of the numbers next to the original cell i am sorting. This will be done on multiple rows and multiple columns.

    Go from this:

    Texta | 3 | Textb | Textaa | 5 | Textbb | Texts | 9 | Textsa | Textg | 1 | Texth |

    To this:

    Textg | 1 | Texth | Texta | 3 | Textb | Textaa | 5 | Textbb | Texts | 9 | Textsa |


    Note: It will always be in the same order as above (text, number, text, text, number, text, etc)

    I attached an example. I also made a cross post in another forum here:
    http://www.mrexcel.com/forum/showthr...31#post2431031
    Attached Files Attached Files
    Last edited by PY_; 09-07-2010 at 09:12 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Sort row but keep adjacent cells tied to sort cell

    I can think of no way to do this with built-in Excel features (though maybe someone else can). I could write some VBA to do this if you answer one question. Your example just shows one row. With multiple rows, is each row sorted independently?

    Is this a one-time job, or will you need to do the same thing repeatedly?
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Sort row but keep adjacent cells tied to sort cell

    Multiple rows independently

    Similar to the following:

    Please Login or Register  to view this content.
    Etc..

    It will need to be ran on a single Workbook after the user Calls the macro (by pressing a button i create) whenever the data needs to be exported.


    I basically have alot of data being gathered from multiple sheet tabs into a single sheet tab. Once gathered, i need to sort it all (using the above method), clean it all up by removing blanks cells/rows/columns, and finally export that sheet tab to a csv file. This will be done on a per job basis so the numbers i am sorting will always be different but the cell locations remain the same.
    Last edited by PY_; 09-01-2010 at 12:39 PM.

  4. #4
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Sort row but keep adjacent cells tied to sort cell

    Here is a final sample file without sort. The sorting will be done on this file before saving as a csv.

    The "XMRX" is just a filler that gets deleted.

    The sorting is done from J:HW on multiple rows all individually


    XMRX gets deleted and shifted left by the following:



    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Sort row but keep adjacent cells tied to sort cell


  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Sort row but keep adjacent cells tied to sort cell

    PY_, thanks for posting your resolution. I apologize that I have been too busy to get back to you on this one.

  7. #7
    Forum Contributor PY_'s Avatar
    Join Date
    09-23-2008
    Location
    Houston
    MS-Off Ver
    Office 2016
    Posts
    289

    Re: Sort row but keep adjacent cells tied to sort cell

    The 03 version doesnt seem to sort correctly. I tried to figure out why but so far no luck (VBA noob here). It does the copy to the vertical column and then copy back into the cells correctly just the sorting seems to flip flop cells around for lack of a better term.

    I can use the 07 and just make sure i call up 07 before running the code whenver i need it. Thanks again for the 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