Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4616798
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:02:03+00:00 2026-05-22T02:02:03+00:00

I am using Excel 2007 with a workbook that has many sheets. I need

  • 0

I am using Excel 2007 with a workbook that has many sheets. I need to have the date when the worksheet was last saved – in the footer. I was able to find the following:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

Dim ws As Worksheet

For Each ws In ThisWorkbook.Worksheets
With ws.PageSetup
.LeftFooter = "Last Save Time: &T"
.RightFooter = "Last Save Date: &D"
End With
Next ws

Set ws = Nothing

End Sub

This changes every worksheet. I need it to only change a sheet that has been edited (so each worksheet can have a different date).
Is this even possible? Should I use a cell instead of a footer? Or do I have to create multiple workbooks?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:02:04+00:00Added an answer on May 22, 2026 at 2:02 am

    As Remnant suggested, best approach would be to utilize the Worksheet_Change event. That means, you need this VBA code

    Private Sub Worksheet_Change(ByVal Target As Range)
        With Me.PageSetup
            .LeftFooter = "Last Change Time: " & Format(VBA.Time, "hh:mm:ss")
            .RightFooter = "Last Change Date: " & Format(VBA.Date, "dd/mm/yy")
        End With
    End Sub
    

    in every of your worksheets. This event is only raised when you change a cells content, not when you change the selection, so it may be what you want.

    Remnant also wrote that this would be a “pain to set up” if you have many worksheets. I think that depends on what you call “many”. For up to 20~40 worksheets, the code from above can be easily copied manually to every sheet in a few minutes.

    If you already have a workbook and a lot (say, more that 40) sheets, then it may be a good idea to add the code programmatically. Add a separate module to your workbook, containing this code, and run it once:

    Option Explicit
    Sub InsertCode()
        Dim VBProj As Object
        Dim VBComp As Object
        Dim CodeMod As Object
        Dim sh As Worksheet
        Dim LineNum As Long
    
        Set VBProj = ActiveWorkbook.VBProject
        For Each sh In ThisWorkbook.Sheets
            Set VBComp = VBProj.vbcomponents(sh.Name)
            Set CodeMod = VBComp.CodeModule
            With CodeMod
                .DeleteLines 1, .CountOfLines
                LineNum = .CreateEventProc("Change", "Worksheet")
                LineNum = LineNum + 1
                .InsertLines LineNum, "Me.Pagesetup.LeftFooter = ""Last Change Time: "" & Format(VBA.Time, ""hh:mm:ss"")"
                .InsertLines LineNum + 1, "Me.Pagesetup.RightFooter = ""Last Change Date: "" & Format(VBA.Date, ""dd/mm/yy"")"
            End With
        Next
    End Sub
    

    This will add the “Worksheet_Change” event from above to the code section of every sheet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel 2007 workbook which I am using to connect to a
I have an access 2007 Database that outputs a report in excel format, the
I'm developing an Excel 2007 add-in using Visual Studio Tools for Office (2008). I
I am currently building an Excel 2007 Add-in using VSTO (latest version + sp1)
I'm using a series of ToolStrips in an Excel 2007 Actions Pane. I'm programatically
What's the better way to insert cell comments in excel 2007 files programmatically using
I'm using the Excel interop in C# ( ApplicationClass ) and have placed the
The print functionality of Excel (using VBA) is extremely slow. I'm hoping someone has
I'm trying to add comments to cells in an Excel 2007 spreadsheet. I'm using
I have written a macro in excel 2007 to log water-level readings. Once logged,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.