Runtime error?

tony_d

Board Regular
Joined
Sep 27, 2003
Messages
229
I have used the following successfully for 2 years but due to an upgrade it now results in an error?
All it used to do was shut the macro sheet thus stopping anyone from 'accidentley altering' the macros enclosed in it.


Workbooks("Macros").Close savechanges :=False
I now get a runtime error
Subscript out of range

Now using excel 2003 on XP

Thanks guys
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
shut the macro sheet

Is this a sheet or a workbook? Your code closes a workbook. If that is correct, try .xls in the workbook name.

Code:
Workbooks("Macros.xls").Close savechanges:=False

Note that this will error if it is already closed...so:
Code:
Dim wb as Workbook
For each wb in Workbooks
If wb.Name = "Macros.xls" Then
Workbooks("Macros.xls").Close savechanges:=False
end if
next wb
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,388
Members
448,957
Latest member
Hat4Life

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