+ Reply to Thread
Results 1 to 8 of 8

Copy multiple columns x number of times based on variable number?

  1. #1
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Copy multiple columns x number of times based on variable number?

    So what I would like to do is take Columns E, F, and G and copy those columns to the right (formatting and formulas included) x number of times based on a cell variable.

    This is my code below but it seems to do what I am asking right for the first time, but then it just copies Column G for all of the other columns:

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy multiple columns x number of times based on variable number?

    I posted twice, oops.
    Last edited by Arkadi; 06-19-2017 at 03:26 PM.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy multiple columns x number of times based on variable number?

    I believe you want offset, not resize, and that will still cause overlap that way, but try this:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: Copy multiple columns x number of times based on variable number?

    Quote Originally Posted by Arkadi View Post
    I believe you want offset, not resize, and that will still cause overlap that way, but try this:

    Please Login or Register  to view this content.
    So that code works where it copies each of the three columns over correctly. However, the only issue is that it repeats the code for 3 times the necessary amount.

    If you remove the m*3 portion of the code it does not copy each individual column over correctly.

  5. #5
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy multiple columns x number of times based on variable number?

    m*3 is just how far over the code moves the copied data. If you assign "ColumnCount" a value of 3, my code would copy E:G 3 times... is that not what you want?

  6. #6
    Valued Forum Contributor
    Join Date
    04-24-2014
    Location
    United States
    MS-Off Ver
    Office 365 ProPlus
    Posts
    853

    Re: Copy multiple columns x number of times based on variable number?

    Quote Originally Posted by nobodyukno View Post
    So that code works where it copies each of the three columns over correctly. However, the only issue is that it repeats the code for 3 times the necessary amount.

    If you remove the m*3 portion of the code it does not copy each individual column over correctly.
    Unsure what you are doing. I ran this code and it copied over 2 times. The m * 3 is telling it how many columns to shift right when copying over. Since you have 3 columns, it is looking to start 3 columns over.


    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    12-29-2012
    Location
    usa
    MS-Off Ver
    Excel 2016
    Posts
    325

    Re: Copy multiple columns x number of times based on variable number?

    Quote Originally Posted by Arkadi View Post
    m*3 is just how far over the code moves the copied data. If you assign "ColumnCount" a value of 3, my code would copy E:G 3 times... is that not what you want?
    Sorry you're right, I was making my ColumnCount formula to complicated to try to incorporate the addition of 3 columns.

    Thanks for the help!

  8. #8
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Copy multiple columns x number of times based on variable number?

    No need to apologize, I thought maybe I misunderstood something...
    Glad it worked out

+ 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 Column x number of times based on cell value?
    By nobodyukno in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-09-2017, 11:20 AM
  2. Use VBA to copy sheet number of times based on cell?
    By ColdWater in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-25-2017, 09:40 PM
  3. Copy and Paste names using a variable for the number of times
    By miles44 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-04-2015, 03:13 PM
  4. [SOLVED] Calculate average of variable number of cells variable number of times
    By WeirnetherlandsBart in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-06-2014, 10:11 AM
  5. Copy Cell Values in two Columns down x number of times then jump and copy some more.
    By scholly23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-02-2014, 03:19 AM
  6. [SOLVED] VBA loop to copy a worksheet a number of times, assign name each time based on loop number
    By TBG in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-29-2012, 10:54 PM
  7. VBA; copy paste number of times based on cell value
    By photopidge in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2011, 03:17 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