+ Reply to Thread
Results 1 to 8 of 8

VBA to copy and paste in batches

  1. #1
    Registered User
    Join Date
    09-20-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    VBA to copy and paste in batches

    Hi All,

    I think this should be simple for some guys here, but I am relatively new to VBA, and so am no good at starting code from scratch.

    I have 2 files (source and dashboard). In my Source file I have a "Data for pasting" sheet with over 45000 rows and 70 columns; and I need to copy the content of this sheet into my dashboad file in a sheet called "Iss Data Paste".

    The issue here is that in my dashboard file I have 7 sheets full of formulas that calculate from the "Iss Data Paste" sheet. And when I do the copy-paste values excel cannot refresh all the sheets in the file dashboard and it returns "#N/A" everywhere. I tried with calculation option manual, but still when I hit F9 i get the errors. Also I tried the copy sheet and it did not work.

    I think, the only option left here is to have a VBA code that will copy the rows 100 at the time from source to dashboard and give the dashboard file to calculate before pasting another batch. In sumary the code needs to do this:

    1- Copy line 1 to 100 from the "data for pasting" sheet sheet "source" file
    2- Paste values in the "iss Data Paste" Sheet in the Dashboad file
    3- Calculate all formulas in the dashboad file
    4- Check that the next batch has some data
    5- Copy line 101 to 200 from the "data for pasting" sheet sheet "source" file
    6- Paste values in the "iss Data Paste" Sheet in the Dashboad file
    7- Calculate all formulas in the dashboad file
    8 repeat copy, paste, and calculate steps until if finds that the next batch is only blanck cells

    To bad I dont know how to write the code. I will appreciate your help on this code.

    Oscar
    Last edited by osfares; 06-10-2014 at 10:20 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    re: VBA to copy and paste in batches

    Hi Oscar
    I am not sure you need VBA to achieve your goal. The #N/A is Excel telling you that a value you are using in your formula is not available.
    Are you able to post a sample so we can see what is going on, even if you have to anonymise the data.
    Tony

  3. #3
    Registered User
    Join Date
    09-20-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    re: VBA to copy and paste in batches

    Hi Tony,

    The #N/A, in this case, is because it cannot calculate. I am sure of that. And I get the errors: "Excel ran out of resources while attempting to calculate one or more formulas. As a result, thses formulas cannot be evaluated" followed by the error "Not enough resources to display completely"
    The data structure, names, and everything else is the same, but the data is so massive that Excel breaks when calculating, leaving me with only #N/A. I checked my formulas and they are correct.

    Thanks
    Last edited by osfares; 06-10-2014 at 11:41 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    re: VBA to copy and paste in batches

    Hi Oscar
    have a look at this link and see if it helps you:

    http://office.microsoft.com/en-gb/ex...010095249.aspx

    Good luck.
    Tony

  5. #5
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    re: VBA to copy and paste in batches

    Hi
    Now you have provided details of a second error message I understand your issue more . Basically it appears to be a System Resource issue which may be down to either a lack of RAM availability if you have other memory hungry programs running or insufficient RAM. Sometime it is down to how you are trying to achieve your end goal and I amnot sayijng in this case that is your issue. It reminds me of an issue an ex colleague of mine wasw having a few years ago where his worksheet contained over 3500 formulas and he was getting the same error message sometimes. having review what he was trying to achieve I was able to replace his 3500+ formulas with 5 separate formulas. Problem solved.
    Hope this helps.
    Tony

  6. #6
    Registered User
    Join Date
    09-20-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    re: VBA to copy and paste in batches

    Tony, I wish this would be the same case; but it is not. I already optimized the formulas. Actually, this is a template someone else created and I was able to decrease it size by 25%, and removed non necessary formulas. Said this, I think I have to live with it and make it a case without solution. Just as an FYI I have 51,500 formulas in the book.
    Thanks for your replies, still I think that the macro top copy portions of the databroken by batches of 50 will help, can you help me with that code?
    Thanks in advance
    Last edited by osfares; 06-10-2014 at 05:28 PM.

  7. #7
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: VBA to copy and paste in batches

    Hi Oscar
    Lets not give up too easily. Are you able to anonymise the data and send me a copy (you could send it to my personal email if you wish).
    Let me know.
    Tony

  8. #8
    Registered User
    Join Date
    09-20-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: VBA to copy and paste in batches

    Tony, I can not send any file to an external email. I will try to install Excel as a 64-bit edition. I read somewhere else that this could help

+ 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] sum by batches
    By Mega_gerry in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-05-2014, 05:49 PM
  2. Copy multiple batches of data using VBA
    By ormerods in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-07-2013, 10:41 AM
  3. [SOLVED] How can I multiply in batches?
    By woodysv650 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-22-2013, 06:55 AM
  4. 2 Macro's: only vertical copy/paste action and copy-paste 14 columns to the right.
    By vdongen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2010, 10:34 AM
  5. Replies: 1
    Last Post: 01-04-2005, 06:06 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