ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   AutoNew (https://www.excelbanter.com/excel-programming/283025-autonew.html)

Kas

AutoNew
 
I have created an Excel template that has a macro that
needs to run when the new spreadsheet is created. The
only way I could get to run was to place the code in the
the ThisWorkbook object using this subroutine Sub
Workbook_Open(). However, I only want this macro to run
when the spreadsheet is first created, not everytime it
opens. What should I be using to accomplish this? Any
help would be greatly appreciated.


GJones

AutoNew
 

-----Original Message-----
I have created an Excel template that has a macro that
needs to run when the new spreadsheet is created. The
only way I could get to run was to place the code in the
the ThisWorkbook object using this subroutine Sub
Workbook_Open(). However, I only want this macro to run
when the spreadsheet is first created, not everytime it
opens. What should I be using to accomplish this? Any
help would be greatly appreciated.

.
Go into VBA into the ThisWorkBook object. Create a macro

that reads the sheet names each time there is a sheet
change. Sheet change is a resever function available in
the drop downs. If there is a new sheet name call the
macro in an IF statement.

Thanks,

Greg

Tom Ogilvy

AutoNew
 
Private Sub Workbook_Open()
if Thisworkbook.Path = "" then
' workbook has not yet been saved
' run you code here
end if
End Sub

--
Regards,
Tom Ogilvy

Kas wrote in message
...
I have created an Excel template that has a macro that
needs to run when the new spreadsheet is created. The
only way I could get to run was to place the code in the
the ThisWorkbook object using this subroutine Sub
Workbook_Open(). However, I only want this macro to run
when the spreadsheet is first created, not everytime it
opens. What should I be using to accomplish this? Any
help would be greatly appreciated.





All times are GMT +1. The time now is 10:12 PM.

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