+ Reply to Thread
Results 1 to 15 of 15

Slow Copy And Paste

  1. #1
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Slow Copy And Paste

    Hi All,

    Im having a little trouble with refining some vba in regards to a copy and paste performing slowly.

    Here is what I am using:
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Which runs slowly, probably becasue its copying the enitre columns.

    Here is what I am attempting to use:
    Please Login or Register  to view this content.
    But I get a run time error 1004 on the line
    Please Login or Register  to view this content.
    What am I doing wrong?

    Thanks!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Slow Copy And Paste

    This is my guess.
    I do not know why are using like if you have a single worksheet, so I assumed that you want to loop through sheets and pick a sheet.
    I am also not sure what is sheet x.

    Untested code.


    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Slow Copy And Paste

    FWIW:

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Slow Copy And Paste

    Quote Originally Posted by AB33 View Post
    This is my guess.
    I do not know why are using like if you have a single worksheet, so I assumed that you want to loop through sheets and pick a sheet.
    I am also not sure what is sheet x.

    Untested code.
    Quote Originally Posted by JOHN H. DAVIS View Post
    FWIW:
    Thanks Guys, sorry about the confusion, looking back at my original post I should have included the entire code and its purpose, not just the area I was looking to alter. Here is the entire code:
    Please Login or Register  to view this content.
    The idea here is to copy and paste data from an already open workbook without knowing the full name of the book or sheet the data is on. Both will contain the word "Changes" in its name, hence the wild cards.
    With these new variables defined, do you both still recommend the code you have provided?

    Thanks!

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Slow Copy And Paste

    I would not do looping through open books. It would be faster to go through open files. What happens if you want loop through 100 open books, do they have to be some where on my PC windows?

  6. #6
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Slow Copy And Paste

    Quote Originally Posted by AB33 View Post
    I would not do looping through open books. It would be faster to go through open files. What happens if you want loop through 100 open books, do they have to be some where on my PC windows?
    The user will have at most 3-5 excel workbooks open at any given time, they are temporary files with exported data from a database. How would you improve looping through open files instead of workbooks?
    Thanks!

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Slow Copy And Paste

    No, I meant you use workbook.open method. Why can not save these tpm files in tmp folder and then open each wb from that tmp? I believe this work faster than looping though active wb.

    You can also use ADO method and works on closed workbook. Please refer to Ron Deburin's site for ADO.

  8. #8
    Forum Guru Izandol's Avatar
    Join Date
    03-29-2012
    Location
    *
    MS-Off Ver
    Excel 20(03|10|13)
    Posts
    2,581

    Re: Slow Copy And Paste

    Quote Originally Posted by Pierce Quality View Post
    Here is what I am attempting to use:
    Please Login or Register  to view this content.
    But I get a run time error 1004 on the line
    Please Login or Register  to view this content.
    What am I doing wrong?

    Thanks!
    If you will copy entire columns, you may not past anywhere except row 1 of target sheet because the copied area will not fit! You may try:
    Please Login or Register  to view this content.
    • Please remember to mark threads Solved with Thread Tools link at top of page.
    • Please use code tags when posting code: [code]Place your code here[/code]
    • Please read Forum Rules

  9. #9
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Slow Copy And Paste

    Quote Originally Posted by AB33 View Post
    No, I meant you use workbook.open method. Why can not save these tpm files in tmp folder and then open each wb from that tmp? I believe this work faster than looping though active wb.

    You can also use ADO method and works on closed workbook. Please refer to Ron Deburin's site for ADO.
    Thanks, I will definitely check Rons site out, ive visited it a few times, but not for ADO.

    Quote Originally Posted by Izandol View Post
    If you will copy entire columns, you may not past anywhere except row 1 of target sheet because the copied area will not fit! You may try:
    Thanks Izandol, your method works well! It does grab a little too much data though, I;m just trying to grab the data in columns A:H (more data exists outside this range), and not the header (in row 1).
    When I tried changing
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    I still got the header. Also, I wasnt able to manipulate just the A:H range. Please help!

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Slow Copy And Paste

    If you a header in the region and want to exclude it.

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Slow Copy And Paste

    Quote Originally Posted by AB33 View Post
    If you a header in the region and want to exclude it.

    Please Login or Register  to view this content.
    Thanks, that makes sense! Is there a way to only copy the data in columns A:H as well?

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Slow Copy And Paste

    One of the 2.

    Please Login or Register  to view this content.

  13. #13
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Slow Copy And Paste

    Quote Originally Posted by AB33 View Post
    One of the 2.
    Thank you very much, I used this one:
    Please Login or Register  to view this content.
    The first one only copied the first two rows of data for some reason.
    Thanks again, marking this as solved!

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Slow Copy And Paste

    How about this?

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor Pierce Quality's Avatar
    Join Date
    07-29-2013
    Location
    USA
    MS-Off Ver
    Excel 2010
    Posts
    221

    Re: Slow Copy And Paste

    Quote Originally Posted by AB33 View Post
    How about this?

    Please Login or Register  to view this content.
    I'll give this one a try too, 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. [SOLVED] Slow Copy and Paste
    By DukeRondo in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 06-27-2014, 07:40 PM
  2. Copy/paste macro is running slow
    By Kaplan275 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-26-2012, 08:28 AM
  3. Excel 2007 : Excel 2007 copy - paste - very slow
    By Doolafs in forum Excel General
    Replies: 6
    Last Post: 07-03-2009, 03:19 AM
  4. [SOLVED] Excel copy/paste slow
    By plunk25 in forum Excel General
    Replies: 2
    Last Post: 06-12-2006, 10:10 PM
  5. copy and paste very slow
    By Alan in forum Excel General
    Replies: 2
    Last Post: 08-05-2005, 05:05 PM

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