ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Stops Executing (https://www.excelbanter.com/excel-programming/433480-code-stops-executing.html)

gims289

Code Stops Executing
 
I have code that copies and existing tab into a new spreadsheet then saves
the new spreadsheet. There is code after that that will close the newly
formed spreadsheet and activate the previous spreadsheet. Problem is that
after the code to save the new spreadsheet runs, the code just stops
executing (doesnt continue to close the new file). Furthermore, the new
spreadsheet doesnt get save €“ even though the file name at the top shows
that it was saved. Any help would be appreciated.

'Make a copy of the letter
Sheets("Letter 1").Copy
Sheets("Letter 1").Name = GrpNumber

'Save the workbook €“ variables have been previously defined
ActiveWorkbook.SaveAs FileName:= _
"G:\Filepath.xls", _
FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

ActiveWindow.Close

Windows("Previous File.xls").Activate
Sheets("Letter 1").Select


Don Guillett

Code Stops Executing
 
Sub CopyShttofile()
grpnumber = "New Name"
Sheets("Letter 1").Copy
ActiveWorkbook.SaveAs Filename:=grpnumber
ActiveWindow.Close
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"gims289" wrote in message
...
I have code that copies and existing tab into a new spreadsheet then saves
the new spreadsheet. There is code after that that will close the newly
formed spreadsheet and activate the previous spreadsheet. Problem is that
after the code to save the new spreadsheet runs, the code just stops
executing (doesnt continue to close the new file). Furthermore, the new
spreadsheet doesnt get save €“ even though the file name at the top shows
that it was saved. Any help would be appreciated.

'Make a copy of the letter
Sheets("Letter 1").Copy
Sheets("Letter 1").Name = GrpNumber

'Save the workbook €“ variables have been previously defined
ActiveWorkbook.SaveAs FileName:= _
"G:\Filepath.xls", _
FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

ActiveWindow.Close

Windows("Previous File.xls").Activate
Sheets("Letter 1").Select




All times are GMT +1. The time now is 03:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com