Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Greetings,
I'm created a new Excel file on the fly and copying a specific worksheet into that new file. This part is fine, until I try to close that new file (see last file of code) and get the error msg: Run time error 9 subscript out of range. Here's the logic in the code: newFname = "NewEXCELfile.XLS" Set NewWks = Workbooks.Add(1).Worksheets(1) With NewWks .Parent.SaveAs FileName:=newFname, FileFormat:=xlWorkbookNormal End With NewWks.Name = "MyNewSheet" Set destrange = NewWks.Range("A1:z100") Set sourceRange = ThisWorkbook.Sheets("SHEET1").Range("A1:z100") sourceRange.Copy destrange.PasteSpecial xlPasteColumnWidths, , False, False destrange.PasteSpecial xlPasteFormats, , False, False destrange.PasteSpecial (xlPasteFormulas) application.CutCopyMode = False Workbooks(newFname).Close Many thanks... |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
error message : I can't close my PERSONAL.XLS file | New Users to Excel | |||
Everytime i close an excel file, it creates a new backup file | Excel Discussion (Misc queries) | |||
Let me save/close EXCEL if a formula I put in has an error in it | Setting up and Configuration of Excel | |||
Error trying to close down dbase IV file used for input to excel | Excel Programming | |||
Adding an error message at close of file when criteria are met | Excel Discussion (Misc queries) |