+ Reply to Thread
Results 1 to 12 of 12

Combine multiple sets of columns into a singe set of columns

  1. #1
    Registered User
    Join Date
    05-18-2017
    Location
    london
    MS-Off Ver
    2013
    Posts
    11

    Combine multiple sets of columns into a singe set of columns

    Hi all,

    Long time lurker, first time poster here.

    I have a spreadsheet with columns of data in A-B-C for a dataset I need to analyze. Then, the same headers are repeated in columns E-F-G, and there is a blank column between these data sets in column D. This same format of headers are repeated again for 100s of columns, and this goes on for 100s of rows. It's a gant repeating dataset, and I'm looking to mere it all together into 3 columns.

    Example:

    Columns go Date-Tag-Value-Blank-Date-Tag-Value-Blank-Date-Tag-Value, etc, etc.

    End result would be all the data merged together as Date-Tag-Value. The first row are headers.

    Can anyone help with some VBA here? The best I have found was the following, but it appears broken.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Combine multiple sets of columns into a singe set of columns

    Hi umchem, welcome to Excel Forum. I haven't tested this code yet, but this is roughly what you're looking for:
    OK, copy this code to a standard module. You'll need to change the "Sheet1" to whatever your Worksheet name is.
    Please Login or Register  to view this content.
    Give me time to test, check back in 20 minutes. -Lee
    OK, good to go. Give this a shot. You can test it on the attached workbook.

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Attached Files Attached Files
    Last edited by leelnich; 05-19-2017 at 10:10 AM. Reason: Updated Code

  3. #3
    Registered User
    Join Date
    05-18-2017
    Location
    london
    MS-Off Ver
    2013
    Posts
    11

    Re: Combine multiple sets of columns into a singe set of columns

    Lee,
    Thank you very much !!!

    Works beautifully! You made my day, great start to the weekend.

  4. #4
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Combine multiple sets of columns into a singe set of columns

    Happy to help, thank you for the rep!

  5. #5
    Registered User
    Join Date
    05-18-2017
    Location
    london
    MS-Off Ver
    2013
    Posts
    11

    Re: Combine multiple sets of columns into a singe set of columns

    Hello again,

    So I appear to have run into a wall. My intent was to analyze this data in a pivot table, however I may have reached the limits of the excel sheet. I am not sure.
    The above macro errors, telling my I cannot copy and paste due to different area sizes.

    Running the macro on a smaller dataset works beautifully. Can anyone help me with this?

    I have attached a link the file here.

  6. #6
    Registered User
    Join Date
    05-18-2017
    Location
    london
    MS-Off Ver
    2013
    Posts
    11

    Re: Combine multiple sets of columns into a singe set of columns

    I was thinking, if this problem is indeed due to Excel's number of row limitations, can the VBA code be modified to consolidate every 100th row?

    In the example, data is recorded every 5 seconds, however I only really need an average so every nth row can be used to plot and study.

    I have no idea how to modify it to grab every 100th row and merge. Can any one help out ?

    Much appreciated

  7. #7
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Combine multiple sets of columns into a singe set of columns

    Yes, I can do that. Give me 45 minutes. Also, I'm curious. Select your worksheet and press CTRL+END to go to the last used cell on your worksheet. What is its address?
    NOTE: END key may be the "1" key on your Number Pad. Turn off NumLock and try it.

  8. #8
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Combine multiple sets of columns into a singe set of columns

    Alright, try this:
    Please Login or Register  to view this content.
    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee

  9. #9
    Registered User
    Join Date
    05-18-2017
    Location
    london
    MS-Off Ver
    2013
    Posts
    11

    Re: Combine multiple sets of columns into a singe set of columns

    Hi Lee,

    Hitting CRTL+END takes me to Column16379, row 17845, and the cell is empty, along with most of the range in this area of the table.

  10. #10
    Registered User
    Join Date
    05-18-2017
    Location
    london
    MS-Off Ver
    2013
    Posts
    11

    Re: Combine multiple sets of columns into a singe set of columns

    I seem to be getting a visual basic error of "400" running the script. I have unloaded all my addins and am trying different things to get around this.

    Im assuming the script runs for you- search google for more info seems to suggest 400 is a mysterious error and very vague. I have tried it on two different computers and received the same error.

    I am thinking this is linked to the CRTL+END giving me a cell way outside the data area of the table.

    UPDATE: ALL WORKS NOWS! I copy and pasted the data as values to remove formatting, thanks again Lee!
    Last edited by umchem; 05-19-2017 at 08:35 AM.

  11. #11
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Combine multiple sets of columns into a singe set of columns

    Great! BTW, you may be able to save more data. When I ran it on your sample, it generated ~50000 rows, taking every 50th record, meaning about 2.5m total records. Excel tops out at 1.04m, so you could keep every 3rd record safely. To do that, change the STP variable to 3 in the code.
    Please Login or Register  to view this content.
    Last edited by leelnich; 05-19-2017 at 09:50 AM.

  12. #12
    Registered User
    Join Date
    05-18-2017
    Location
    london
    MS-Off Ver
    2013
    Posts
    11

    Re: Combine multiple sets of columns into a singe set of columns

    Thanks Lee, much appreciated, you have really helped me out here.

+ 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] Moving multiple columns (8 x sets of 3) with data in separate rows into 3 columns
    By Emmax in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 03-03-2016, 01:23 PM
  2. Replies: 6
    Last Post: 11-25-2015, 01:01 PM
  3. [SOLVED] Macro sorting multiple sets of columns
    By Roger1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-12-2015, 06:46 PM
  4. [SOLVED] Combine Multiple Worksheet Change Events in a Singe Woksheet
    By Kimston in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-21-2015, 11:48 AM
  5. Macro to combine multiple columns keeping few columns specific
    By lramesh in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-16-2013, 12:44 PM
  6. [SOLVED] Compare multiple sets of columns
    By bseo927 in forum Excel General
    Replies: 7
    Last Post: 08-19-2013, 01:16 PM
  7. Replies: 0
    Last Post: 07-31-2006, 12:13 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