+ Reply to Thread
Results 1 to 5 of 5

Rearrange Data

  1. #1
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299

    Rearrange Data

    I have a data set that I need to re-arrange. In the original data set, year, month, & day are in separate columns, in the new data set this is combined as a single date field. The id field in the original data becomes columns in the new set and finally the data for the new set is the max value of the 24 columns pertaining to the id and date. Those 24 columns in the old data represent hours. The new data set is daily maxiums of that hourly data re-arranged to show the id as columns and date as rows. Is there a macro that could make my life easier!!!

    Thank you.
    Attached Files Attached Files

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Re-arrange Data

    Hello erock24,

    Well, that was fun. The macro below has been added to the attached workbook. It creates a condensed report on a new sheet I added called "Sheet1". You can change the name to whatever you like.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Forum Expert
    Join Date
    03-31-2009
    Location
    Barstow, Ca
    MS-Off Ver
    Excel 2002 & 2007
    Posts
    2,164

    Re: Re-arrange Data

    I have put a macro into Testfile2.xls. I added Worksheets("Sheet1"), so you can compare your results on Worksheets("New") with the results from the macro. Note: I sorted the results by date, which is different than your data on Worksheets("New").

    Erase the data on Worksheets("Sheet1") and run "ArrangeData()". If you're satisfied that it works, then change "Sheet1" to "New" at the end of the Macro.

    Never mind. I like Leith's macro better.
    Last edited by foxguy; 05-11-2010 at 10:15 PM. Reason: liked Leith's macro better

  4. #4
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299

    Re: Re-arrange Data

    Leith Ross, Thank you very much for the reply, your macro works exactly as i needed. I do have a follow-up question though. In the original data, if col A corresponded to sheet names, could the macro condense the data to that sheet?? I supplied a new example where there are 2 data sets stacked on top of each other "m71" and "m31". I would need "m71" condensed to that sheet and "m31" data condensed to the other. If this is doable, the real data set will contain six stacks.

    Thank you for your time and help.
    Attached Files Attached Files

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Re-arrange Data

    Hello erock24,

    It is doable. I will need to make some changes to the macro. Once I have it working I'll post back.

+ 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