Any worksheet event that you want to extend to all sheets in the workbook should go into a workbook-level sheet event. For example, if you use a Change or SelectionChange event in a worksheet, and you want to have the same functionality in all worksheets, you would rather have just one event procedure (SheetChage or SheetSelectionChange) in ThisWorkbook. That applies to any other sheet event and is good practice. Another thing I often do is using the NewSheet event to add a link to a list of contents (if you have that) when a new sheet is created. I also used that event to format every new sheet, for example, the code below copies the headers and format of a reference sheet to every new sheet: Private Sub Workbook_NewSheet(ByVal Sh As Object) 'copy headers from reference sheet to new sheet Sheets(1).Rows(1).Copy Sh.Paste 'copy format to new sheet Sheets(1).Cells.Copy Sh.Cells.PasteSpecial (xlFormats) End Sub
Thanks mate, it will help me a lot
Nice Explained.
Hi! Do you have any examples regarding workbook sheet change events?
Any worksheet event that you want to extend to all sheets in the workbook should go into a workbook-level sheet event. For example, if you use a Change or SelectionChange event in a worksheet, and you want to have the same functionality in all worksheets, you would rather have just one event procedure (SheetChage or SheetSelectionChange) in ThisWorkbook. That applies to any other sheet event and is good practice. Another thing I often do is using the NewSheet event to add a link to a list of contents (if you have that) when a new sheet is created. I also used that event to format every new sheet, for example, the code below copies the headers and format of a reference sheet to every new sheet:
Private Sub Workbook_NewSheet(ByVal Sh As Object)
'copy headers from reference sheet to new sheet
Sheets(1).Rows(1).Copy
Sh.Paste
'copy format to new sheet
Sheets(1).Cells.Copy
Sh.Cells.PasteSpecial (xlFormats)
End Sub
@@ExcelMacroMania Thanks for clarifying that! Excelent! :)