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

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

xenou

MrExcel MVP
Joined
Mar 2, 2007
Messages
16,836
Office Version
  1. 2019
Platform
  1. Windows
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,191,482
Messages
5,986,840
Members
440,052
Latest member
silverandcoldmc

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
Top