+ Reply to Thread
Results 1 to 9 of 9

Copy Column Values to Rows with Spacing

  1. #1
    Registered User
    Join Date
    11-06-2018
    Location
    Florida
    MS-Off Ver
    Office 365
    Posts
    12

    Copy Column Values to Rows with Spacing

    Hello, I'm attempting to write a vba code that will copy the contents from specific columns over into rows on a separate sheet and start a new row for each column item added. Difficult to explain but if you look at the attached spreadsheet you'll see that I'm wanting to copy from the "Source" sheet over to "Destination" sheet. Essentially swapping column to row data but the addition of a row for each "image" cell content requires an additional row which complicates it. I attempted to use the Macro recording feature but cannot get it to repeat for the entire sheet which is roughly 115k rows.


    There's probably a much simpler way to go about doing this then the poor attempt at code I've attached.

    Any help you can provide is appreciated.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2502 Win 11
    Posts
    24,537

    Re: Copy Column Values to Rows with Spacing

    This is a simple procedure in Power Query/Get and Transform. Here is the MCode

    Please Login or Register  to view this content.
    Attached is the file for your review.
    Attached Files Attached Files
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    365
    Posts
    199

    Re: Copy Column Values to Rows with Spacing

    Here is my quick and dirty implementation purely in VBA:
    Please Login or Register  to view this content.

  4. #4
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    729

    Re: Copy Column Values to Rows with Spacing

    try

    Please Login or Register  to view this content.
    Regards,
    MohanS


    "Perfection is not attainable, but if we chase perfection we can catch excellence." - Vince Lombardi

    You can simply say thanks by clicking "*Add Reputation" icon

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy Column Values to Rows with Spacing

    Try
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    08-26-2014
    Location
    Finland
    MS-Off Ver
    365
    Posts
    199

    Re: Copy Column Values to Rows with Spacing

    Just for fun I tried all 3 different code solutions and here are the runtimes of each (3 runs average):

    Mine: 0.01171875
    JinDon: 0.0234375
    Mohan: 0.0390625

    Pretty similiar in execution time, so unless you work with massive amounts of data every solution should be equal at this part :D

    I have a I6700k, would love to know the runtimes with different systems

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Copy Column Values to Rows with Spacing

    Please Login or Register  to view this content.
    Last edited by jindon; 02-08-2019 at 09:39 AM.

  8. #8
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2502 Win 11
    Posts
    24,537

    Re: Copy Column Values to Rows with Spacing

    Did you try the Power Query solution?

  9. #9
    Registered User
    Join Date
    11-06-2018
    Location
    Florida
    MS-Off Ver
    Office 365
    Posts
    12

    Re: Copy Column Values to Rows with Spacing

    So, for some reason I couldn't get the power query to work correctly for me. It may have just been my in experience using it.

    However, the VBA code from banaanas worked like a charm. Thank you everyone for the assist and suggestions.


    Please Login or Register  to view this content.

+ 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] Copy values from columns with multiple rows into one column
    By wayneroad in forum Excel General
    Replies: 6
    Last Post: 12-13-2015, 06:07 PM
  2. Replies: 2
    Last Post: 03-18-2015, 05:31 AM
  3. Copy rows into Template Sheet if values in Column B & L, B & R or Both.
    By corneliusj in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-17-2014, 08:55 PM
  4. Copy rows from one worksheet to another, where column values are the same
    By klauber in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-26-2013, 01:55 PM
  5. Replies: 4
    Last Post: 01-31-2013, 03:15 AM
  6. Copy rows that match values in a column of names
    By lunatyck in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-13-2012, 11:22 AM
  7. Rows Spacing, Column Spacing
    By Pukka83 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-26-2008, 12:05 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