+ Reply to Thread
Results 1 to 15 of 15

How to copy specific column from one sheet to another

  1. #1
    Forum Contributor
    Join Date
    08-18-2018
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    147

    How to copy specific column from one sheet to another

    How to copy specific columns from sheet2 to sheet1 with dynamic rows. Columns are not continuous so I can't range it as column ("A:D") for example. My code below does copy the values but it takes longer as it is per cells and it's like looping. How can I copy it in the fastest way possible using vba?

    Please Login or Register  to view this content.
    Last edited by dummy777; 06-04-2020 at 07:38 PM.

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: How to copy specific column from one sheet to another


    Hi,

    for standard rows you can extract each desired column at once without any loop …
    Last edited by Marc L; 06-04-2020 at 10:35 AM.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: How to copy specific column from one sheet to another

    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Forum Contributor
    Join Date
    08-18-2018
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    147

    Re: How to copy specific column from one sheet to another

    Quote Originally Posted by Mumps1 View Post
    It would be easier to help and test possible solutions if you could attach a copy of your file. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary). See the yellow banner at the top of this page for instructions to attach a file.
    Hi, I can't attached file as I'm using my computer in my work

    Quote Originally Posted by Marc L View Post

    Hi,

    for standard rows you can extract each desired column at once without any loop …
    How can I do that without a loop? I will just modify my code in "For, Next"?

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: How to copy specific column from one sheet to another


    As it depends on how smart is the source worksheet - I'm a very beginner as mind-reader - with its regular rows
    but yes a loop is useless as you can copy data column by column : if you operate manually, do you copy cell by cell or column by column ?!
    As the easy way is to reproduce what you can already achieve manually just activating the Macro Recorder to get your own code base …
    If you need further help it seems you missed the top page yellow banner …

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,810

    Re: How to copy specific column from one sheet to another

    Manually create a mock-up file at home with generic data that is organized in exactly the same way as your actual file. Perhaps you can use the original headers. Include just enough data to make the mock-up exactly representative of the original data. Then describe what you want to do in detail referring to specific cells, rows, columns and sheets, using a few examples from the data and attach the mock-up file here.

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow Re: How to copy specific column from one sheet to another


    In the original code, two Variant variable are created as Worksheet object, used everywhere except in the Lastrow codeline ‼
    So this Lastrow comes from the active sheet and as we can't guess which is the active sheet neither reading the initial 'explanation' …

  8. #8
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: How to copy specific column from one sheet to another

    Based on your code, you could re-write it like below assigning the whole column data all at once instead of looping through each cell. If this still doesn't help, then I guess you have to post a sample file

    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  9. #9
    Forum Contributor
    Join Date
    08-18-2018
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    147

    Re: How to copy specific column from one sheet to another

    Quote Originally Posted by nankw83 View Post
    Based on your code, you could re-write it like below assigning the whole column data all at once instead of looping through each cell. If this still doesn't help, then I guess you have to post a sample file

    Please Login or Register  to view this content.
    Thank you once again nankw for helping me. It really works well.

  10. #10
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: How to copy specific column from one sheet to another

    Glad to help & thanks for the reps

  11. #11
    Forum Contributor
    Join Date
    08-18-2018
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    147

    Re: How to copy specific column from one sheet to another

    Quote Originally Posted by nankw83 View Post
    Glad to help & thanks for the reps
    You're welcome!

    Also, how can I not include the headers in .Columns(3).value?

  12. #12
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: How to copy specific column from one sheet to another

    You can use Offset like below … I have change the sheet1 to start from row #2 I guess

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    08-18-2018
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    147

    Re: How to copy specific column from one sheet to another

    Quote Originally Posted by nankw83 View Post
    You can use Offset like below … I have change the sheet1 to start from row #2 I guess

    Please Login or Register  to view this content.
    Thank you very much, yes its working. then I also tried below. I'm learning so much from you.

    Please Login or Register  to view this content.

  14. #14
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: How to copy specific column from one sheet to another

    This is the beauty of the forum where we all learn something new everyday Yes, your code does the same thing but why write the offset(1) 3 times if it could be written only once

    Please don't quote the whole reply, if necessary to quote, just quote the needed statement - Take couple of minutes to read the forum rules HERE

  15. #15
    Forum Contributor
    Join Date
    08-18-2018
    Location
    Canada
    MS-Off Ver
    2013
    Posts
    147

    Re: How to copy specific column from one sheet to another

    Thank you!

+ 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. VBA to copy all rows in any sheet with 1 in column A and copy entire row to specific sheet
    By Lazarus Rises in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-21-2020, 02:17 AM
  2. [SOLVED] Copy specific column data from one sheet to another sheet using Certain filter Criteria
    By xlhelp7 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-02-2017, 12:09 AM
  3. Copy Column A from Sheet containing Specific Word and Past it into last sheet
    By mangesh.mehendale in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-01-2015, 01:04 AM
  4. [SOLVED] Copy rows with specific text in specific column into specific sheet
    By Valemaar in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 08-22-2014, 03:23 PM
  5. [SOLVED] Copy cells in another sheet if 1st sheet has a certain color in a specific column
    By ccellarius32 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-02-2014, 05:08 PM
  6. Copy a specific row/column to another sheet
    By zicktechnology in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-24-2013, 05:15 AM
  7. [SOLVED] Copy variable range from sheet to the last row with a specific blank column in new sheet
    By seputus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-22-2012, 07:29 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