Consulting

Results 1 to 2 of 2

Thread: Time Stamp VBA - Need help please!

  1. #1
    VBAX Newbie
    Joined
    Aug 2008
    Posts
    1
    Location

    Question Time Stamp VBA - Need help please!

    I was fortunate enough to run across the following code from this site..


    [VBA] Option Explicit
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Range("A7").Value = "vbGeneralDate"
    Range("B7").Value = FormatDateTime(Now, vbGeneralDate)
    Columns("A:B").EntireColumn.AutoFit
    Range("A1").Select
    End Sub [/VBA]

    I need help with the following

    I have 4 worksheets and each one of them has a different number of
    rows.

    I want the date and time stamp to appear at a certain position for
    each of the sheets. For example one is A8 B8 on another sheet it is A 107 B 107
    I need to find a way to have the date stamp appear in different places on different worksheets. Or, Ideally, Have the date stamp appear in the footer. For this project it is very important that I know when the last hard save was done

    Any thoughts/ideas/help on the matter would be greatly appreciated. Glad I found this forum!

    -K

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Dim ws As Worksheet

    For Each ws In ThisWorkbook.Worksheets

    Select Case ws.Name

    Case "ABC"
    ws.Range("A8").Value = "vbGeneralDate"
    wb.Range("B8").Value = FormatDateTime(Now, vbGeneralDate)
    wb.Columns("A:B").EntireColumn.AutoFit

    Case "XYZ"
    ws.Range("A107").Value = "vbGeneralDate"
    wb.Range("B107").Value = FormatDateTime(Now, vbGeneralDate)
    wb.Columns("A:B").EntireColumn.AutoFit

    'etc
    End Select
    Next ws

    ThisWorkbook.Save

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •