+ Reply to Thread
Results 1 to 13 of 13

Macro throwing out 'memory' error

  1. #1
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Macro throwing out 'memory' error

    Hi, I am having 'memory' error issue whilst running a file and wonder if anyone can help tweak the memory to improve the file performance. I am using Excel 2010 version. Thanks in advance.

    I have a master file with numerous country tabs as well as reporting tabs which pull data from the country tabs. Initially I had a macro which activated an essbase retrieve function and populated each of the country tabs. As the number of rows increased (close to 4800 rows and columns extednign to 'DR' now), running this macro has become next to impossible. So I have now gone for having a separate file which just refreshes the essbase retrieves (and this works fine). I have set up a macro in the master file which then opens this source file and copypastes values from each of the tabs into the corresponding country tab in the master file. But this throws up a 'Excel cannot complete this task with available resources. Choose less data or close other applications’…this despite me having closed all other applications. File size of master file is 13MB and that of the source file (where the retrieve is done) is 18MB. So, effectively when I do the transfer, I have both files open.

    I am attaching the code below. I plan to tweak the code to include a 'Do While' to pull all country data. I started initially but trying to pull in two sheets data only and this is crashing...so obvoulsy trying to run this macro for 12 countries is not going to work!!

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Macro throwing out 'memory' error

    apologies..I meant ' tweak the macro'!!

  3. #3
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Macro throwing out 'memory' error

    Hi,

    About the only change I can see that you could make there would be to add
    Please Login or Register  to view this content.
    after each paste
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Macro throwing out 'memory' error

    Firstly, read this: https://www.mrexcel.com/forum/excel-...clipboard.html

    Then google other ways of copying excel data without putting many megabytes on the clipboard.

    Then google how much upgrading to 64bit CPU + O/S + Office is and consider converting to that, cos 64bit removes the memory restriction. Well, I say removes.....Excel 32bit has a a 2Gb memory maximum....no matter how much RAM you've got, Excel will only use 2Gb of it. 64bit Excel has an 8Tb limit......ie 8000Gb.

  5. #5
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Macro throwing out 'memory' error

    Quote Originally Posted by BellyGas View Post
    Excel 32bit has a a 2Gb memory maximum....no matter how much RAM you've got, Excel will only use 2Gb of it.
    That depends on which version you have, and whether your OS is 32 or 64bit- https://support.microsoft.com/en-gb/...ange-for-excel

  6. #6
    Registered User
    Join Date
    08-07-2017
    Location
    Newport, Wales
    MS-Off Ver
    2013
    Posts
    13

    Re: Macro throwing out 'memory' error

    I'm new back here but I think I remember advice that included these bits of code that might be worth looking into:

    Application.ScreenUpdating = False 'To Turn Off at the start of code.
    Application.ScreenUpdating = True 'To Turn on at the end of the code.

    and

    Application.Calculation = xlCalculationManual 'To turn off the automatic calculation
    Application.Calculation = xlCalculationAutomatic 'To turn On the automatic calculation

    That might help until an expert comes along

  7. #7
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Macro throwing out 'memory' error

    Quote Originally Posted by xlnitwit View Post
    That depends on which version you have, and whether your OS is 32 or 64bit- https://support.microsoft.com/en-gb/...ange-for-excel
    That's new, didn't know that. Ta.

  8. #8
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Macro throwing out 'memory' error

    Hi, thanks for the help. I have tried plugging in the suggestions given by xlnitwit and Daminc2 but now it seems to be throwing up a 'Run time error '1004': Method 'Open' of object 'Workbooks' failed' and when I click ok, it says 'Can't execte code in break mode'. On clicking debug, it highlights the 'Set wb1 = Workbooks.Open (Filename:=FileToOpen)' code. Could anyone help? Is it still caused by the memory issue?

    Please Login or Register  to view this content.
    BellyGas..thanks for highlighting the systems/OS issues...since this is a company laptop and network, not sure if I can get much help there...and soon:-(

  9. #9
    Registered User
    Join Date
    08-07-2017
    Location
    Newport, Wales
    MS-Off Ver
    2013
    Posts
    13

    Re: Macro throwing out 'memory' error

    Just a quick thought: Shouldn't the FileFilter include .xlsm? since the workbook is using Macro's?

  10. #10
    Registered User
    Join Date
    08-08-2014
    Location
    Lancaster, PA
    MS-Off Ver
    2016 (windows & mac)
    Posts
    94

    Re: Macro throwing out 'memory' error

    As you're only copying the values and number formats I would avoid using copy/paste all together.

    See if the below works (untested)

    Please Login or Register  to view this content.

  11. #11
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Macro throwing out 'memory' error

    @thatandyward

    That would only work if all the cells have the same number format. Otherwise, the Numberformat will return Null, not an array of formats.

  12. #12
    Registered User
    Join Date
    08-08-2014
    Location
    Lancaster, PA
    MS-Off Ver
    2016 (windows & mac)
    Posts
    94

    Re: Macro throwing out 'memory' error

    Ah. Good to know, wasn't aware of that.

    Thanks for pointing out

  13. #13
    Registered User
    Join Date
    02-02-2014
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    65

    Re: Macro throwing out 'memory' error

    Thanks all...apologies for the delayed response. Had to sift thru all the data and remove as much stuff as required...not ideal as the lost information should now be collected by other means but at least have got the file to work now.

+ 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] Mac throwing error - Runtime Error 429 - ActiveX Component Can't Create Object
    By harman83 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 11-28-2018, 11:04 PM
  2. [SOLVED] Macro not throwing any error but still not going through all worksheets
    By VKS in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 07-29-2017, 04:19 AM
  3. Excel Macro throwing a Syntax Error and I am not sure why
    By budwong27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-14-2017, 03:43 AM
  4. [SOLVED] Macro throwing Overflow error when calculating
    By jonboy6257 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-01-2013, 05:26 PM
  5. Replies: 6
    Last Post: 11-29-2012, 08:56 PM
  6. Macro Error...OUT OF MEMORY
    By G118 in forum Excel General
    Replies: 1
    Last Post: 10-15-2005, 05:05 PM
  7. Error 7 Out of Memory 2/3 through Macro
    By CoderB in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2005, 01:06 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