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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Page Setup Macro runs slow 3
Selecting a newly added and named worksheet 2
Printing Macro 6
Slow PageSetup macro 3
Formula in Header 2
Page setup too slow 2
Worksheet(1).PageSetup 1
Auto populate dates 2

Top