I have a macro that creates a number of worksheets, some of which are just spreadsheets and some are just charts. I need for each of these sheets to have certain code behind them depending on if they are a chart or regular worksheet. Here's the code:

For worksheets:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Row = 1 Then
Sheets("Contents").Select
End If
End Sub

For charts:
Private Sub Chart_BeforeDoubleClick(ByVal ElementID As Long, ByVal Arg1 As Long, ByVal Arg2 As Long, Cancel As Boolean)
If ElementID = 4 Or ElementID = 28 Then
Sheets("Contents").Select
End If
End Sub


I've been advised to try using templates to set the code behind each sheet, but I have no idea how to do that. Is it possible to use VBA to have any created sheets based on a certain template? Naturally, i don't want every sheet in the future to have this code. I need a big hand on this one... Thanks