with workbook_newsheet, how to specify all new sheets ?

G

GregJG

This is what I am using now. but it will only use is on worksheet(2).
have tried () ( ) but nothing seems to work.

I would like to set the margins in all new sheets in this workbook


Private Sub Workbook_NewSheet(ByVal Sh As Object)
With Worksheets(2).PageSetup
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.2)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
End With

End Su
 
D

Dave Peterson

That Sh variable represents the new worksheet:

Option Explicit
Private Sub Workbook_NewSheet(ByVal Sh As Object)
With Sh.PageSetup
.LeftMargin = Application.InchesToPoints(0.25)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.25)
.BottomMargin = Application.InchesToPoints(0.2)
.HeaderMargin = Application.InchesToPoints(0)
.FooterMargin = Application.InchesToPoints(0)
End With

End Sub
 
Top