• Home
  • Blog
  • Resume
  • Contact
  • Projects
  • Gallery
  • Amit’s Resume
  • About Nagpur
KEEP IN TOUCH

Add footer to all the worksheets in a workbook

Nov02
2005
Leave a Comment Written by admin

Using this code you can add the same footer to all the worksheets in your workbook. It’ll ask you for Left, Center and Right footer. Please note that if you want to print all the worksheets with continious page numbers you’d have to select all the worksheets at the same time. This code will do it for select all the worksheets. If you don’t want continious page number select a single sheet.

‘This sub will add the same footer to all the worksheets in your activeworkbook _
‘    and select them and view in printpreview

Sub PrintSettings()
    Dim sht As Worksheet, arrShtNames() As String, shtCount As Long
    Dim strLfooter As String, strCfooter As String, strRFooter As String
    strLfooter = InputBox(“Enter the left footer”, “Left footer”, ThisWorkbook.Name)
    ‘&D will print the date
    strCfooter = InputBox(“Enter the center footer”, “Ccenter footer”, “&D”)
    ‘&P of &N will print page numbers like this: 1 of 5
    strRFooter = InputBox(“Enter the right footer”, “Right footer”, “&P of &N”)
    ‘copy the footer to all the sheets
    Application.ScreenUpdating = False
    For Each sht In ActiveWorkbook.Worksheets
        sht.Activate
            With ActiveSheet.PageSetup
                .LeftFooter = strLfooter
                .CenterFooter = strCfooter
                .RightFooter = strRFooter
            End With
            shtCount = shtCount + 1
            ReDim Preserve arrShtNames(shtCount – 1)
            arrShtNames(shtCount – 1) = sht.Name
    Next sht
    Sheets(arrShtNames).Select
    ActiveWindow.SelectedSheets.PrintPreview
    Application.ScreenUpdating = True
End Sub

Related posts:

  1. Change the creation date of a workbook
  2. Save HTML files from one folder to Excel files in another folder
  3. VBA Samples for Working with Excel 2003 Worksheets
  4. Importing IE bookmark
  5. String Operations
Posted in Uncategorized - Tagged Name Next
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
« Random Text Generator
» XY scatter plot in MS Access

No Comments Yet

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

*

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Tags

Access Alt F8 Books boxplot cells charts count cursor dashboard data mining dbase design error excel excel functions export filter flip LaTex MS query Number Err ODBC pipes Press Alt F11 Public Sub python R random numbers Range Cells report scripting software sparklines SQL SQL server stack columns statistics stemming string tag cloud text mining UDF VBA visualization wildcard

Network

View Ashutosh Nandeshwar's profile on LinkedIn

Recent Comments

  • larry on Access Export to Excel (2007)
  • Betty Chou on Projects
  • Rwill on Access Export to Excel (2007)
  • Bharathi on The search key was not found in any record in Access
  • Michael on The search key was not found in any record in Access

Related Posts

  1. Change the creation date of a workbook
  2. Save HTML files from one folder to Excel files in another folder
  3. VBA Samples for Working with Excel 2003 Worksheets
  4. Importing IE bookmark
  5. String Operations

EvoLve theme by Blogatize  •  Powered by WordPress nandeshwar.info