+ Reply to Thread
Results 1 to 2 of 2

Last Modified

  1. #1
    Steve
    Guest

    Last Modified

    I am looking for a way for excel to auto add the last modified date and time
    as well as the user. I would like the date and time in one cell and the user
    in a seperate cell. Is this something that can be done fairly easily? Any
    help is always appreciated.

    Thanks,
    Steve

  2. #2
    Tom Hutchins
    Guest

    RE: Last Modified

    You will need VBA for this. Copy the following into a VBA code module, to get
    the user's ID from the network (not guaranteed to work on every kind of
    network):

    'Declare API functions
    Public Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA"
    (ByVal lpBuffer As String, nSize As Long) As Long

    Public Function ReturnUserName() As String
    'Returns the NT Domain User Name
    Dim rString As String * 255, sLen As Long, tString As String
    tString = ""
    On Error Resume Next
    sLen = GetUserName(rString, 255)
    sLen = InStr(1, rString, Chr(0))
    If sLen > 0 Then
    tString = Left(rString, sLen - 1)
    Else
    tString = rString
    End If
    On Error GoTo 0
    ReturnUserName = UCase(Trim(tString))
    End Function

    In the ThisWorkbook module, add a Workbook_BeforeSave event routine like the
    following:

    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Range("A4").Value = Now()
    Range("A5").Value = ReturnUserName()
    End Sub

    Hope this helps,

    Hutch

    "Steve" wrote:

    > I am looking for a way for excel to auto add the last modified date and time
    > as well as the user. I would like the date and time in one cell and the user
    > in a seperate cell. Is this something that can be done fairly easily? Any
    > help is always appreciated.
    >
    > Thanks,
    > Steve


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1