Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have this macro which is aimed to close a series of workbooks which may or
may not be open. it works perfectly when all the workbooks detailed are open but tends to get periodically stuck if some of them are shut (although if I keep running the macro eventually everything will close down. When I debug it says "Run time error €˜9 Subscript out of range" is there anyway to get this macro running smoothly as it is really frustrating that is isn't working completely the first time. Sub SaveAndCloseWorkbooks() Dim wbtest As Workbook On Error Resume Next Set wbtest = Workbooks("Bund Current Payoff.xls") On Error GoTo 0 If Not wbtest Is Nothing Then Workbooks("Bund Current Payoff.xls").Close SaveChanges:=True On Error Resume Next Set wbtest = Workbooks("Gilt Current Payoff.xls") On Error GoTo 0 If Not wbtest Is Nothing Then Workbooks("Gilt Current Payoff.xls").Close SaveChanges:=True etc and so forth for 9 more workbooks End sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Macro to autofill from a specific row to a specific row | Excel Discussion (Misc queries) | |||
Macro - specific range | Excel Discussion (Misc queries) | |||
specific macro on specific sheets | Excel Discussion (Misc queries) | |||
How do I set a macro to run at specific times? | Excel Discussion (Misc queries) | |||
Run Macro from specific cells | Excel Programming |