+ Reply to Thread
Results 1 to 12 of 12

Sorting columns by rows

  1. #1
    Registered User
    Join Date
    04-19-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Sorting columns by rows

    Hi, if anyone could help me with this it'd be much appreciated and save a lot of time compared to doing it manually;

    I have in row 1 the time in 30 minute intervals
    In each column I have registration plates, so if someone was parked at 7am they will appear in that column.
    Due to the way the data was recorded, it was entered into excel quite chaotically and as such if someone was parked for 2 hours it is difficult to see this, as in the 7am column they may be in row 2 and in the 7.30am column row 20...

    If anyone has any ideas on how I could sort all the columns so that the data in each column remains in the column but becomes aligned so that every instance of X7Z 123 is in the same row it would be appreciated.

    I'm not really expecting a solution to this as I've already checked in other places and been told it would require some extensive visual basic programming, but thought I'd check just in case.

    Thanks

    Attached is an image of how the data looks, I'd like 1 row dedicated to each individual reg ...

    Using Excel 2003
    Attached Images Attached Images
    Last edited by transportplanner; 04-21-2010 at 04:59 AM.

  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 columns by rows (complicated)

    Hi TransportPlanner. I have a macro I think will do this, I can tweak it for you. Please post up your workbook so I have valid data to test this against. Make sure the sample wb demonstrates a full set of columns.

    Click GO ADVANCED and use the paperclip icon to post up your workbook.
    _________________
    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
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Sorting columns by rows (complicated)

    I'm not sure if this is what you are looking for but see the attached. For the restructured table, I first created a column of unique ID's (plates) and then used the formula in B20, dragged across and down. Is that what you are looking for?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

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

    Re: Sorting columns by rows

    Is this the output you'd expect?
    Please Login or Register  to view this content.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    04-19-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Sorting columns by rows

    ChemistB that's perfect thanks very much :D. I'll have a look around for tutorials on how to do that, but I've got this thread set to instant notification so if anyone could link me to a good one that'd be very much appreciated.

    I've uploaded the actual sheet (didn't see .xls in the allowed upload list first time round).

    Thanks

    P.S, SHG yours is also good, what was your method?
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-19-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Sorting columns by rows

    Hi, just to say I've been completely unable to find a tutorial showing me how to do what you've done with the sorting... so I'm a bit stuck.

    If you anyone knows a good link it'd be much appreciated, thanks.

  7. #7
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Sorting columns by rows

    I found a mistake in my formula (it should have matched SHG's results so I knew I was wrong). In B20, it should refer to column A not B like so
    =IF(ISNA(MATCH($A20,A$3:A$16,0)),"",$A20)
    That can be dragged across and down. Then if you select the entire range, it can sorted alphabetically.

    Explaination. MATCH looks in the 7AM range (A3:A16) for a match from the unique id cell (A20). It will either return a number matching the row (e.g. if the match is in A3, it returns 1, A4, returns 2, etc) or it returns a #NA error if there is no match.
    The ISNA(Match(...)) returns true if it finds an error (no match) and False if there isn't an error (is a match). If there's an error, the IF statement returns a blank (""), if there is no error, it returns the unique ID.

    Hope that helped.
    Last edited by ChemistB; 04-20-2010 at 11:30 AM.

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

    Re: Sorting columns by rows

    If Chemist's solution works for you, stick with that. I used VBA, and there's no need to jump into that end of the pool unless you reallly need to.

  9. #9
    Registered User
    Join Date
    04-19-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Sorting columns by rows

    Brilliant thanks, good explanation - I'll keep a note of this for future reference as I may well forget.

    The other thing I need to know to be able to apply this method to other sheets is how to do the unique ID list, I've been messing around with data > sort and data > filter having looked at various tutorials but all to no avail.

    Thanks very much for the help thus far :D

  10. #10
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Sorting columns by rows

    I think the "Remove Duplicates" is new with Excel 2007 (bummer). There are a couple of quick ways to do this. I think the easiest (no VBA, no Formulas) is to first take all of your values and place them in a single column. Put a header on that column (e.g. Unique IDs) and select the entire range including header. Go to Advanced Filter, select "Copy to another location" (input the first cell of a blank column) and "Unique records only." Click okay and you'll get a list of unique records. Does that work for you?

  11. #11
    Registered User
    Join Date
    04-19-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: Sorting columns by rows

    Thank you very much, I was going wrong by thinking I could select it as it was (multiple rows and columns) rather than putting it all into one column first. I shall change this thread to solved now, thanks :D

    Only other thing now I'm doing it; how does excel know to ignore the field 'Unique IDs' - I've tried that unique filter with and without it, both work - and yet the one with Unique IDs doesn't put Unique IDs into the sorted data. Would probably be useful to know if you'd be willing to explain? Again, thanks very much. Now I can do this in an hour rather than a week.
    Last edited by transportplanner; 04-21-2010 at 05:02 AM.

  12. #12
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Sorting columns by rows

    The Advanced filter requires a header row. In fact, if it doesn't find one, it usually brings up a message box telling you so. It might be taking your first row as your header in which case it's not including that entry in your results (which won't matter if you have a duplicate of it). Best to be safe and include the header row. Excel automatically recognizes it and ignores it.

+ 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