+ Reply to Thread
Results 1 to 6 of 6

Run-time error 7 out of memory vba

  1. #1
    Registered User
    Join Date
    08-17-2012
    Location
    Serbia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Run-time error 7 out of memory vba

    This is my first post here and second day trying to use VBA to solve some problems/shortcuts in Excel (I'm learning by trial and error).
    Using macros and help from this forum I was able to sort some code that I was happy with.
    Problem is when I use second macro (that I found on the net-which is working in blank workbook) I get "Run-time error 7 out of memory"
    in first macro which I am not using at the time.

    The problem is in the third line "If Target.Column = 20 And Target.Value = "B" Then"

    Please Login or Register  to view this content.
    Thanks for help in advance.
    Last edited by Jovica; 08-19-2012 at 09:09 AM.

  2. #2
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    25,538

    Re: Run-time error 7 out of memory vba

    Hi,

    How big is the file?
    Have you got any other applications or Excel workbooks open at the same time? If so close them all and see if that helps.
    Is there only one version of Excel open?
    Richard Buttrey

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-17-2012
    Location
    Serbia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Run-time error 7 out of memory vba

    I've read that help file, tried everything and nothing...same problem.File size is 353kb.
    Code that I put in previous message (let's say Code1) is working until I start another macro (Code2) in the same Excel file.
    Code1 should perform 2-3 operations whenever I put one of 3 letters (B, S or W) into certain column.
    Code2 (that I borrowed from another site) is retrieving financial data into blank sheet.
    Both macros are working but not together, main problem is when I start Code2, the error message appears in Code1.

    Here is Code2 even though nobody had any problem with it:
    Please Login or Register  to view this content.

  4. #4
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    25,538

    Re: Run-time error 7 out of memory vba

    Hi,

    In the absence of the workbook we'll have to guess.

    It may be that the action of code 2 is firing the code 1 macro many times. i.e. every time the many code 2 instructions change the Data sheet.
    What happens if you start the code 2 macro with the instruction
    Application.EnableEvents = False
    and finish it with
    Application.EnableEvents = True

    Why are you using the Workbook Sheet Change event? Are you really wanting it to fire whenever anything is changed anywhere?
    If you use it on a sheet other than the Data Sheet used by code 2, use the Worksheet Change event instead.

  5. #5
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    10,464

    Re: Run-time error 7 out of memory vba

    Part of your problem is that you are using a workbook.sheetchange event. So, when a change is made in any cell in any sheet the event is triggered. Your second macro is changing some sheet and, therefore calling the sheetchange event code. The sheetchange event code is making further changes and, thus calling itself: the changes are calling changes that are calling changes... until you run out of memory.
    You need to turn off event handling while the code is modifying the sheets:

    Please Login or Register  to view this content.
    and:
    Please Login or Register  to view this content.
    Ben Van Johnson

  6. #6
    Registered User
    Join Date
    08-17-2012
    Location
    Serbia
    MS-Off Ver
    Excel 2010
    Posts
    85

    Re: Run-time error 7 out of memory vba

    Thanks you guys. @protonLeah I've tried both corrections and it worked, thank you so much.

+ 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