+ Reply to Thread
Results 1 to 5 of 5

Macro to convert 4 columns of data into rows, then repeat

  1. #1
    Registered User
    Join Date
    08-18-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    5

    Question Macro to convert 4 columns of data into rows, then repeat

    I currently have an excel that lists all the data in columns but I'd like to move it into rows. For Example I have the following

    A01 = Amber
    A02 = Female
    A03 = 23
    A04 = Houston
    A05 = David
    A06 = Male
    A07 = 25
    A08 = Miami
    A09 = Jen
    A10 = Female
    A11 = 25
    A12 = San Francisco


    But I'd like for it to be


    B | C | D | E
    ______________________________________
    Amber | Female | 23 | Houston
    David | Male | 25 | Miami
    Jen | Female | 25 | San Francisco


    I realize I can transpose but there are thousands I'd have to do. Is there an easy macro to do this?

    I've seen other macros but they didn't work because I need specifically 4 columns to data to move into a row, then start next group of 4....
    Any information is greatly appreciate.
    Last edited by liastar; 08-21-2012 at 09:38 PM.

  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: Macro to convert 4 columns of data into rows, then repeat

    Put this first formula in B1, then copy across through E1.

    =INDEX($A:$A, (ROW(A1)*4)+COLUMN(A1)-4)

    Now copy those four cells down until you start seeing zeros.

    Copy the resulting table, then do a Paste Special > Values.

    ---------- Post added at 05:20 PM ---------- Previous post was at 05:15 PM ----------

    ...and for chuckles, a macro that does the same thing:

    Please Login or Register  to view this content.
    _________________
    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
    08-18-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to convert 4 columns of data into rows, then repeat

    Holy dude you are amazing!
    Using the =INDEX($A:$A, (ROW(A1)*4)+COLUMN(A1)-4) worked fine.
    I was expecting that I'd have to use a macro lol

    i <3 you man

  4. #4
    Registered User
    Join Date
    08-18-2012
    Location
    Texas
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Macro to convert 4 columns of data into rows, then repeat

    Actually the macro is better because I can copy and paste the data, whereas the sort code loses its reference if I copy and paste data somewhere else.

  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: Macro to convert 4 columns of data into rows, then repeat

    With the formulas, you would copy, then Paste Special > Values somewhere else.

+ 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