+ Reply to Thread
Results 1 to 11 of 11

Formula to get vertical data into horizontal format

  1. #1
    Registered User
    Join Date
    01-12-2012
    Location
    Orlando, FL
    MS-Off Ver
    2010
    Posts
    46

    Formula to get vertical data into horizontal format

    Hello All-

    I'm trying to find a formula that will help me get vertical data into a horizontal format. I'm thinking it's sort of like a vlookup or index/match that I'm in need of. I've attached a sample spreadsheet with the vertical data and the horizontal format. I appreciate any help that can be provided.

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Formula to get vertical data into horizontal format

    Hi,

    In D3 and copied across....


    =INDEX('Get data from'!$B$3:$B$14,MATCH('Send data to'!D1,'Get data from'!$A$3:$A$14,0))
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Formula to get vertical data into horizontal format

    =INDEX('Get data from'!$B$3:$B$14,MATCH('Send data to'!D$1,'Get data from'!$A$3:$A$14,0),1) -Put this in cell D1 as copy/paste as needed.

    See attached:
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

  4. #4
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,444

    Re: Formula to get vertical data into horizontal format

    I've just noticed that you want to match the account code also, which makes things a little more complex. Can you give a further example of what the source data will look like? Particularly the position of the account id in respect to the list of values to be transposed, and if there are varying lengths of data to be transposed.

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Formula to get vertical data into horizontal format

    Hi razkowski,

    A pivot table can do your work and no formulas are needed. I would question your motive as the original table is how Excel likes to see data best. See the attached with Pivot that does what you want.

    If you have the account code repeated down a column you could filter the pivot using it and deal with them also.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Registered User
    Join Date
    01-12-2012
    Location
    Orlando, FL
    MS-Off Ver
    2010
    Posts
    46

    Re: Formula to get vertical data into horizontal format

    The source data will always appear as shown: Account Code, a blank cell, then the data to be transposed by Period. The data to be transposed can change at times, if there are periods in which the account code was not used. Most will have periods 1 through 12, however, some may be missing a period or two....1,2,5,6,9 etc

  7. #7
    Registered User
    Join Date
    01-12-2012
    Location
    Orlando, FL
    MS-Off Ver
    2010
    Posts
    46

    Re: Formula to get vertical data into horizontal format

    I created the formula shown in this attachment but I'm not quite getting it.

  8. #8
    Registered User
    Join Date
    01-12-2012
    Location
    Orlando, FL
    MS-Off Ver
    2010
    Posts
    46

    Re: Formula to get vertical data into horizontal format

    bump000000

  9. #9
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Formula to get vertical data into horizontal format

    Question - is the source data going to have multiple blocks for different Account numbers? If so, are there spaces between the blocks? When a period is missing, is there a gap where that period would be or not?


    I have a reliable, but fairly slow to calculate version you might be able to use (attached).

    You don't need the Q/R columns in the "Send Data to" tab - I just put them there for illustration. What I'm doing is locating the start and end for each "account block" in the data sheet - then matching the period if possible.

    If there is no match, you get the "#N/A" return as you would expect.

    This solution takes a moment to calculate, probably could be optimized.


    Formulas:



    For period returns (columns D through O):
    =INDEX(INDEX('Get data from'!$B:$B,MyAccountBlock_start):INDEX('Get data from'!$B:$B,MyAccountBlock_end),MATCH('Send data to'!D$1,INDEX('Get data from'!$A:$A,MyAccountBlock_start):INDEX('Get data from'!$A:$A,MyAccountBlock_end),0))


    myAccountBlock_start (named formula):
    =ROW(INDEX('Get data from'!$A:$A,MATCH('Send data to'!$A11,'Get data from'!$B:$B,0)))+2 - enter as an 'array' formula when authored in the name manager.

    MyAccountBlock_end (named formula):
    =MIN(IF((INDEX('Get data from'!$A:$A,MATCH('Send data to'!$A7,'Get data from'!$B:$B,0)+2):'Get data from'!$A$1048571)="",ROW(INDEX('Get data from'!$A:$A,MATCH('Send data to'!$A7,'Get data from'!$B:$B,0)+2):'Get data from'!$A$1048571),""))
    Attached Files Attached Files
    Last edited by GeneralDisarray; 07-07-2015 at 02:15 PM.

  10. #10
    Registered User
    Join Date
    01-12-2012
    Location
    Orlando, FL
    MS-Off Ver
    2010
    Posts
    46

    Re: Formula to get vertical data into horizontal format

    Yes. There are approximately 2,000 sections just like the one on the "Get data from" tab in my original attachment. There will be an account number with periods and amounts below. Then another section with a different account number/periods/amounts and so on. I believe that's the issue with my formula. I'm able to match on the account number because it's unique. However, I'm having difficulty matching on the periods because they aren't unique. I'm praying for one of you guru's to help me break through at this point.

    Thanks

  11. #11
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: Formula to get vertical data into horizontal format

    --EDIT---

    Add some columns (something like what I've done) to make a unique key column - then hit off that column.

    See attached new example.



    The previous example required no new columns but it wasn't very memory friendly - the trick to this one was finding a way to assign a block ID to the b column on the data tab.
    Attached Files Attached Files
    Last edited by GeneralDisarray; 07-07-2015 at 02:32 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Get horizontal data into vertical format using macro or formula
    By Sukhdev.Singh in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2015, 06:47 PM
  2. Replies: 1
    Last Post: 08-15-2014, 12:18 PM
  3. [SOLVED] Change data from vertical format to horizontal format
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2013, 07:06 PM
  4. [SOLVED] Macro to convert vertical data in horizontal format
    By ajang in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-27-2013, 06:03 PM
  5. Convert data From Vertical to Horizontal Format
    By reyrey in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-20-2011, 03:52 PM

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