Runtime Error: "Out of Memory" From Excel Macro

Posted by user356180 on Stack Overflow See other posts from Stack Overflow or by user356180
Published on 2010-06-09T05:29:44Z Indexed on 2012/06/12 22:40 UTC
Read the original article Hit count: 119

Filed under:

I have one macro, which is called when a cell change occurs. This macro selects images, deletes them, and inserts another image depending on a cell value using the following code. I have the same code for two sheets.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ActiveSheet.Shapes.SelectAll
    Selection.Delete
    'insert image code here.
End Sub

In one sheet, it's working perfectly fine and deletes all images, while in the other sheet, it gives me the runtime error "Out of Memory" and highlights the following line:

 ActiveSheet.Shapes.SelectAll

Can anyone tell me why this is happening? It works perfectly fine in one and not in the other.

One other thing I want to tell you is it was working fine when I gave this Excel macro to my client; both sheets were working fine. Suddenly after 2 days, he started getting the error on one sheet on which he was working a lot.

I don't know why this is happening. Can anyone tell me what's the reason for this and how I can solve it?

© Stack Overflow or respective owner

Related posts about excel-vba