+ Reply to Thread
Results 1 to 6 of 6

Changing Column Data into Row Data

Hybrid View

  1. #1
    Registered User
    Join Date
    09-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Changing Column Data into Row Data

    Hey Genius Community

    I have a ton of data (attached a sample) that is driven by formula. The way I have the data set up is I would have A,B,C,D..... in column A and on the top row I have YTD, 1 year, 3 year and 5 year..... and so on column headers. I want to be able to pivot and slice data and therefore want data to be in the following format (example file: "Desired Output) A,B,C,D in col A and YTD, 1year, 3 year and 5 year in col B and each associated value to be in each row corresponding accordingly. I want this in such that when original data changes so should that output. I have tried using the pivot trick and double clicking on grand total and then pivoting off that but it doesn't work.

    Please help. TIA
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,414

    Re: Changing Column Data into Row Data

    Do you want the new format on another sheet, or to the right of the data that you currently have?

    Pete

  3. #3
    Registered User
    Join Date
    09-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Changing Column Data into Row Data

    Another sheet is preferred. I have a lot of data...

  4. #4
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,414

    Re: Changing Column Data into Row Data

    Okay, assuming you have suitable headings in row 1 of Sheet2, you can use these formulae in the cells stated:

    A2: =INDEX(Sheet1!A:A,INT((ROWS($1:1)-1)/4)+3)

    B2: =INDEX(Sheet1!$B$2:$E$2,MOD(ROWS($1:1)-1,4)+1)

    C2: =INDEX(Sheet1!$B$3:$E$11,INT((ROWS($1:1)-1)/4)+1,MOD(ROWS($1:1)-1,4)+1)

    The 11 in the final formula (shown in blue) is to suit your sample data - change this to suit your real data, then you can copy these formulae down as far as you need to, and they will respond immediately to changes in the original data.

    Hope this helps.

    Pete

  5. #5
    Registered User
    Join Date
    09-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    7

    Re: Changing Column Data into Row Data

    at Pete_UK - anyway to explain the C2 formula?

  6. #6
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,414

    Re: Changing Column Data into Row Data

    The syntax for INDEX is:

    INDEX(table,row,column)

    It will return the element of the table from the appropriate row and column values. The row term is thus:

    INT((ROWS($1:1)-1)/4)+1

    and when this is copied down the ROWS($1:1) becomes ROWS($1:2), then ROWS($1:3) and so on in successive rows. These terms will return 1, then 2, then 3 etc., and you can see that 1 is subtracted from those values each time (resulting in 0, 1, 2 etc.) and the formula takes the integer value of that number divided by 4, so we will get 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, and so on, to which 1 is added, so we will get data from the first row of the table four times, and then from the second row of the table four times, and so on.

    The column term is given by:

    MOD(ROWS($1:1)-1,4)+1

    and MOD returns the remainder after division, so the ROWS($1:1)-1 will return 0, 1, 2, 3, 4, 5 etc. when the formula is copied down. The MOD(...,4) will return 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, and so on, and we add one on to those values, so we are getting data from the first column of the table, then the second column, then the third, then the fourth, and then back to the first column, etc. as the formula is copied down.

    Hope this helps.

    Pete

    P.S. If that takes care of your original question, please select Thread Tools from the menu above your first post and mark this thread as SOLVED.
    Last edited by Pete_UK; 05-13-2016 at 05:01 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. Replies: 2
    Last Post: 01-27-2015, 12:10 PM
  2. [SOLVED] Another formula for changing data in column A if data in column B matches
    By zellvdw in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-05-2013, 12:44 PM
  3. Renaming/changing data in a column ...??
    By Mtn Breeze in forum Excel General
    Replies: 2
    Last Post: 01-21-2011, 11:19 PM
  4. Excel 2007 : Changing all Data in a Certain Column
    By iNetGeezer in forum Excel General
    Replies: 2
    Last Post: 05-26-2010, 03:12 PM
  5. Changing the data in a column
    By twilsonmi in forum Excel General
    Replies: 8
    Last Post: 03-22-2007, 06:11 PM
  6. Changing entire column data
    By Collegestudent05 in forum Excel General
    Replies: 1
    Last Post: 03-09-2005, 05:06 PM
  7. Changing data in a column
    By jerry chapman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-01-2005, 12:06 AM

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