LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 24
Default Add standard header and footer to new worksheet

I am a VBA novice writing an Excel 2002 template. I wish to add a standard
header and footer to any new worksheet that is added. My attempt to achieve
this has fallen at the first hurdle! Can anyone help me with this?

My code is:-

Private Sub Workbook_NewSheet(ByVal Sh As Object)
Dim ws As Worksheet
Dim fs As String
fs = "Ariel Size 8" ' Font Size
fc = "FF0000" ' Colour = Red
Application.ScreenUpdating = False
Set ws = ActiveWorkbook.Worksheets
With ws.PageSetup
.LeftHeader = ""
.CenterHeader = "My Company Name" & fs & "K(fc)"
.RightHeader = ""
.LeftFooter = "&F" & Chr(10) & "&A" & fs & "K(fc)" 'Document Name and
Workbook Name
.CenterFooter = ""
.RightFooter = "&D" & Chr(10) & "&T" & fs & "K(fc)" 'Current date and
Current Time
End With
Set ws = Nothing
End Sub



Thanks in anticipation.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Show where worksheet is saved in the header/footer Justyna Excel Discussion (Misc queries) 6 September 4th 07 05:00 PM
Duplicate A5 worksheet with header & footer onto an A4 original Peter Newman Excel Discussion (Misc queries) 0 December 7th 06 01:47 PM
how to include a variable in the header and/or footer of a worksheet tmacke Excel Discussion (Misc queries) 2 April 14th 06 10:13 PM
Is it possible to copy a header/footer from one worksheet to anoth DLC Excel Discussion (Misc queries) 1 September 28th 05 02:01 PM
Landscape worksheet with portrait header/footer SNOWED-IN Excel Discussion (Misc queries) 3 April 11th 05 05:18 AM


All times are GMT +1. The time now is 12:11 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"