+ Reply to Thread
Results 1 to 11 of 11

Overflow Error - Faster way of copying through macro

  1. #1
    Forum Contributor
    Join Date
    01-13-2009
    Location
    Mumbai
    MS-Off Ver
    Excel 2003, 2007
    Posts
    168

    Overflow Error - Faster way of copying through macro

    Hi,
    I am transferring 10000 rows from 1 workbook to another..

    It takes place smoothly for the first 30000 rows, but after that on the 'select' line it gives me an overflow error.

    The code that I am using is as following:

    Please Login or Register  to view this content.
    Here xlverfile is the other workbook which changes with every for loop..

    Hope I can get some solution.. I get the error on the .select line.

    Regards,
    Vaibhav
    Last edited by c.vaibhav; 12-02-2009 at 01:21 AM.

  2. #2
    Forum Contributor
    Join Date
    01-13-2009
    Location
    Mumbai
    MS-Off Ver
    Excel 2003, 2007
    Posts
    168

    Re: Overflow Error while copying 10000 rows from one workbook to another

    oops.. I am so sorry..

    I Had declared i as integer.. it should have been long..

    regards,
    vaibhav

  3. #3
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Overflow Error while copying 10000 rows from one workbook to another

    hi vaibhav,

    Your code can be shortened to the below (change the "Range("a123")" as needed.
    ".Select" & ".activate" are rarely needed in macros & modifying your code to work without them will help your code run faster.

    Please Login or Register  to view this content.
    hth
    Rob
    Rob Brockett
    Kiwi in the UK
    Always learning & the best way to learn is to experience...

  4. #4
    Forum Contributor
    Join Date
    01-13-2009
    Location
    Mumbai
    MS-Off Ver
    Excel 2003, 2007
    Posts
    168

    Re: Overflow Error

    Hi Rob,

    Thanks for the help..
    but the code doesnt seem to work on my PC..

    that screenupdating part is fine.. however the one line code for copying and pasting is not working..

    i get the following error:

    Copy Method of range class failed.

    Error - 1004

    Probably because I am copying across workbook.. Also these two workbooks are not in the same instance of excel.. I have opened a new instance of excel..

    Is there any faster way to deal with my problem.

    Regards,
    Vaibhav
    Last edited by c.vaibhav; 11-19-2009 at 02:01 PM.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Overflow Error - Faster way of copying through macro

    Also these two workbooks are not in the same instance of excel..
    That's not going to work.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Overflow Error - Faster way of copying through macro

    I'm having trouble understanding how the original version worked, if the other file (how is xlverfile defined?) is in a separate instance of Excel. Does it need to be?

    Rob

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Overflow Error - Faster way of copying through macro

    Reckon you could paste from the Office clipboard, but wonder why the need to be open in separate instances.

  8. #8
    Forum Contributor
    Join Date
    01-13-2009
    Location
    Mumbai
    MS-Off Ver
    Excel 2003, 2007
    Posts
    168

    Re: Overflow Error - Faster way of copying through macro

    I am no more facing the overflow error.

    I'll explain you why I am using different instances of excel..

    Actually the new files thus created needs to processed. i.e. I have a toolbar which has the macro in it. If I open the workbooks in the same excel then I would not be able to run the toolbar macro on each of these workbooks simultaneously.. rather If I open the new workbooks in a new instance of excel then I can run the toolbar Macro simultaneously and my work gets divided. The toolbar macro takes a long time to process the data..

    I was wondering if there could be a faster way of copying 10000 rows across workbooks in different excel instances..

    Regards,
    Vaibhav

  9. #9
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Overflow Error - Faster way of copying through macro

    Hi Vaibhav,

    I am no more facing the overflow error.
    If the problem of this thread is solved, can you please post your final code (for others who come across the thread while searching), & mark the thread as Solved?

    I suggest starting a new thread about your speed issue & posting all your processing code. Someone may be able to suggest ways of optimising/speeding it up so dramatically that your files no longer need to be divided!
    Edit: To provide background you could provide a link to this thread in your new thread.

    Rob
    Last edited by broro183; 11-30-2009 at 05:41 PM.

  10. #10
    Forum Contributor
    Join Date
    01-13-2009
    Location
    Mumbai
    MS-Off Ver
    Excel 2003, 2007
    Posts
    168

    Re: Overflow Error - Faster way of copying through macro

    ohhh.. actually the error got resolved just by changing the data type from integer to long..

    I really need to reduce the processing speed.. but the logic of macro has become too complex..

    I surely will have to start a new thread.. thanks rob for the suggestion..

    regards,
    vaibhav

  11. #11
    Forum Expert
    Join Date
    01-03-2006
    Location
    Waikato, New Zealand
    MS-Off Ver
    2010 @ work & 2007 @ home
    Posts
    2,243

    Re: Overflow Error - Faster way of copying through macro

    Good as gold, chuck a link to the new thread in to this one when you create it...

    Rob

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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