krodriguez
Board Regular
- Joined
- Jul 11, 2012
- Messages
- 119
Hello,
I have the below code which attempts to select several sheets in a wordbook and save them on a separate file, but I'm getting the “Runtime-error '9'”: Subscript out of range, can someone assist to fix it? Thanks
Sub SaveSheetsAsFiles()
Dim SheetsToSave
SheetsToSave = Array("Rainbow", "RLN-Net Realization RLN-Red Rev RLN-COGS", "RLN-Logistics", "RLN-R&D", "RLN-Selling RLN-Administrative", "RLN-Advertising", "RLN-Sales Promo") 'change tab names to suit
Application.ScreenUpdating = False
For Each sht In Sheets(SheetsToSave)
sht.Copy
'file location is same as workbook the code is in. Change to suit
'file format is .xlsm - change to suit
ActiveWorkbook.SaveAs Filename:=sht.Name & ".xlsm", FileFormat:=52
Next sht
Application.ScreenUpdating = True
End Sub
I have the below code which attempts to select several sheets in a wordbook and save them on a separate file, but I'm getting the “Runtime-error '9'”: Subscript out of range, can someone assist to fix it? Thanks
Sub SaveSheetsAsFiles()
Dim SheetsToSave
SheetsToSave = Array("Rainbow", "RLN-Net Realization RLN-Red Rev RLN-COGS", "RLN-Logistics", "RLN-R&D", "RLN-Selling RLN-Administrative", "RLN-Advertising", "RLN-Sales Promo") 'change tab names to suit
Application.ScreenUpdating = False
For Each sht In Sheets(SheetsToSave)
sht.Copy
'file location is same as workbook the code is in. Change to suit
'file format is .xlsm - change to suit
ActiveWorkbook.SaveAs Filename:=sht.Name & ".xlsm", FileFormat:=52
Next sht
Application.ScreenUpdating = True
End Sub