out of memory error

Flyingmeatball

Board Regular
Joined
Aug 15, 2007
Messages
65
I keep getting an out of memory error and I'm not quite sure why. I have an excel spreadsheet open that isn't terribly involved. I've set up some security, so I run a macro on the workbook close that forces the user to save and switch to a security tab. Because it saves automatically, i added a userform that would give them the option to cancel out of closing, in case the accidentally clicked on the little x. To run this userform, i set up two public variables. If they click "Yes" on the userform, my exit script should run successfully. If they click "No" on the userform, it should return cancel to the Workbook_Beforeclose, and nothing should happen. Here is the code of my workbook_beforeclose:

Private Sub Workbook_BeforeClose(Cancel As Boolean)

RunEscape = False
CancelEscape = False

ExitDialog.Show
MsgBox ("Cancelescape is " & CancelEscape)
MsgBox ("RunEscape is " & RunEscape)
If CancelEscape = True Then Cancel = True

If RunEscape = True Then

'removes assumptions
If ActiveSheet.Name = "MySheet" Then
Range("D:I").Select
Selection = cb.ClearDataND
Selection.clear
End If
'code below will make your created sheet visible
Sheets("Security").Visible = True
'code below will hide your working sheet
Sheets("mySheet").Visible = xlVeryHidden
cb.SetCBAutoLoad (False)
Me.Save
End If

End Sub

and here are my useform buttons:

Private Sub Yesbutton_Click()
RunEscape = True
ExitDialog.Hide
End Sub

Private Sub Nobutton_Click()
CancelEscape = True
ExitDialog.Hide
End Sub



does anyone know why I could be getting this error?

Thanks!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,224,586
Messages
6,179,710
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top