bluepenink
Well-known Member
- Joined
- Dec 21, 2010
- Messages
- 585
hello
below is a code i use to format my workbooks..however i was wondering if someone can help me make it apply towards a single worksheet...currently if i run the macro, it applies this on all worksheets in the workbook.
thx u
below is a code i use to format my workbooks..however i was wondering if someone can help me make it apply towards a single worksheet...currently if i run the macro, it applies this on all worksheets in the workbook.
thx u
Code:
Sub marginsheader()
' creates left, right, top and bottom margins; header and footer; blue border title and printing
Dim objSheet As Object
Application.ScreenUpdating = False
For Each objSheet In ActiveWorkbook.Sheets
With objSheet
With .PageSetup
.RightHeader = "&""Arial,Regular""&8DRAFT"
.LeftFooter = "&""Arial,Regular""&8&F"
.CenterFooter = "&""Arial,Regular""&8Confidential"
.RightFooter = "&""Arial,Regular""&8Page: &P of &N"
.LeftMargin = Application.CentimetersToPoints(0.25)
.RightMargin = Application.CentimetersToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.37)
.BottomMargin = Application.InchesToPoints(0.41)
.HeaderMargin = Application.InchesToPoints(0.2)
.FooterMargin = Application.InchesToPoints(0.23)
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = False
End With
If TypeOf objSheet Is Worksheet Then
.Columns("A:B").ColumnWidth = 0.75
.Columns("P:Q").ColumnWidth = 0.75
.Rows("1:2").RowHeight = 5.25
'change range below for desired blue fill for title
Range("C3:O3").Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 10027008
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.Weight = xlThin
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With Selection.Font
End With
Selection.Font.Bold = True
End If
End With
Next objSheet
Application.ScreenUpdating = True
End Sub