+ Reply to Thread
Results 1 to 10 of 10

Consolidate many columns into three

  1. #1
    Registered User
    Join Date
    07-15-2013
    Location
    Italia
    MS-Off Ver
    Excel 2011
    Posts
    17

    Question Consolidate many columns into three

    Dear all,

    I am new to this forum and I apologize for any error in posting this question (right place/ right format etc..).

    I am also new to VBA, but I program in C++ and R, so I can follow your hints.

    Here's my problem: I have a database in Excel which is formatted in a strange way: three variables repeated many times but with a different number of observations each time, for example...

    Variable 1 Variable 2 Variable 3 Variable 1 Variable 2 Variable 3 Variable 1 Variable 2 Variable 3
    34 57 21 65 67 89 9 1 20
    12 45 68 53 89 32 16 72 14
    14 54 87 9 2 4 6 98 24
    23 54 98 76 34 90 14 21 65
    12 53 87 9 63 97
    45 76 76

    .. and I need:

    Variable 1 Variable 2 Variable 3
    34 57 21
    12 45 68
    14 54 87
    23 54 98
    65 67 89
    53 89 32
    9 2 4
    76 34 90
    12 53 87
    45 76 76
    9 1 20
    16 72 14
    6 98 24
    14 21 65
    9 63 97

    Thank you very much for your help!

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Consolidate many columns into three

    Well I can't imagine it would take that long to set this up manually (select D2:F2, ctrl+shift+down arrow, copy and paste to first empty row in col A, repeat for H2:I2) but as a coded version, assuming your data starts at A1:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Consolidate many columns into three

    I'm only posting this because I was working on this as well and this approach will work for any number of columns on the worksheet. It's a few more lines of code than yudlugar's excellent example but meh, there's always more than one way to skin a c.., anyways
    Please Login or Register  to view this content.
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Consolidate many columns into three

    For what it's worth, I'd use this for arbitrary number of columns
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    07-15-2013
    Location
    Italia
    MS-Off Ver
    Excel 2011
    Posts
    17

    Re: Consolidate many columns into three

    Thank you very much, yudlugar and Mordred! I'll ask you something a bit more complicated, which is the real-life problem I'm actually facing right now. I have many many sheets formatted like this, and many of these small "tables", otherwise I'd do it by hand...

    The actual table I'm facing begins like this

    And I'd need something like this.

    Thanks again!
    Attached Images Attached Images
    Last edited by Wilco84; 07-15-2013 at 11:48 AM.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Consolidate many columns into three

    That is gobbledygook to me...

  7. #7
    Registered User
    Join Date
    07-15-2013
    Location
    Italia
    MS-Off Ver
    Excel 2011
    Posts
    17

    Re: Consolidate many columns into three

    Sorry, I hope you can view the tables now in some way...

  8. #8
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Consolidate many columns into three

    haha, looks a bit better now, afraid I still can't view those images on my work server though. It would be best to upload a workbook with your desired tables on separate worksheets.

    To upload:
    -when replying click - go advanced, then attachments.

  9. #9
    Registered User
    Join Date
    07-15-2013
    Location
    Italia
    MS-Off Ver
    Excel 2011
    Posts
    17

    Re: Consolidate many columns into three

    Here comes the attachment...
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Consolidate many columns into three

    I think you need something like this (run it with the "what i have" sheet active):
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    07-15-2013
    Location
    Italia
    MS-Off Ver
    Excel 2011
    Posts
    17

    Re: Consolidate many columns into three

    Thank you so much, yudlugar!!! You are the man!
    Wow, you saved me so much time! Thanks!!!

+ 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. Consolidate 3 columns of emails into 1
    By KLRob in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-05-2013, 07:49 AM
  2. How do I Consolidate Like Columns to One Quantity
    By bgrizam2005 in forum Excel General
    Replies: 1
    Last Post: 02-27-2012, 11:30 PM
  3. Replies: 2
    Last Post: 06-14-2011, 12:39 PM
  4. Consolidate some columns into a row
    By martinez_pedro in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-27-2011, 06:09 PM
  5. Consolidate Columns w/ Pivot Chart
    By smninos in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 09-03-2009, 11:25 AM

Tags for this Thread

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