Closed Thread
Results 1 to 6 of 6

Excel 2007 : Converting horizontal data to vertical data (more than just transposing)

  1. #1
    Registered User
    Join Date
    04-21-2010
    Location
    Preston, Lancs
    MS-Off Ver
    Excel 2007
    Posts
    7

    Converting horizontal data to vertical data (more than just transposing)

    Hi,

    I have data in a horizontal format that I would like to convert into a vertical format.

    The following is an extract of the data -:

    Postcode Trade 01-Apr 02-Apr 03-Apr 04-Apr 05-Apr
    AB A 1 1 1 1 2
    AB B 1 1 1 0 1
    AB C 1 1 1 1 2
    AB D 3 3 2 2 4
    AB E 0 0 0 0 1
    AB F 1 1 0 0 1
    AB G 0 0 0 0
    AL A 3 3 2 2 4
    AL B 1 1 1 1 2
    AL C 1 1 1 1 2
    AL D 3 3 2 2 4
    AL E 6 6 5 4 8
    AL F 1 1 1 0 1
    AL G 1 1 1 1 2
    AL H 1 1 0 0 1

    The columns extend right out to 31-Mar i.e one for each day of the year.
    ----------------------------------------------------------------------------------------------------------------------------------

    I have been asked to present the data, vertically, as follows -:

    Postcode Date Trade Amount
    AB 01-Apr-10 A 1
    AB 02-Apr-10 B 1
    AB 03-Apr-10 C 1
    AB 04-Apr-10 D 1
    AB 05-Apr-10 E 2

    i.e. each day of the year has to be listed against each category in the Trade column. This makes a total of over 300k rows. I have went through the painful process of copying and pasting (transposing) and I have done all the postcodes and dates.

    Would anybody know any way of formulating the amount across from horizontal to vertical? I have looked into a few different formulas to no avail.

    Thanks
    Last edited by glens73; 04-23-2010 at 03:39 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: Converting horizontal data to vertical data (more than just transposing)

    This will do it, but it will take a while on that large a data set. Run this on a copy of your sheet.
    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
    04-21-2010
    Location
    Preston, Lancs
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Converting horizontal data to vertical data (more than just transposing)

    Thanks very much, works perfectly.

    Out of curiousity, did you write this specifically or is it a macro you already knew that you just had to tailor a bit.

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

    Re: Converting horizontal data to vertical data (more than just transposing)

    I wrote it for you based on your sample data.

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

    Re: Converting horizontal data to vertical data (more than just transposing)

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  6. #6
    Registered User
    Join Date
    04-21-2010
    Location
    Preston, Lancs
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Converting horizontal data to vertical data (more than just transposing)

    Quote Originally Posted by JBeaucaire View Post
    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

    I've done that.

    Cheers again, I really appreciate the help.

Closed 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