+ Reply to Thread
Results 1 to 5 of 5

Logging changes by users to a separate sheet or workbook on the same shared drive

  1. #1
    Registered User
    Join Date
    01-19-2015
    Location
    Virginia
    MS-Off Ver
    2007
    Posts
    29

    Logging changes by users to a separate sheet or workbook on the same shared drive

    Good morning,

    I would like to be able to log the activity of others on a spreadsheet so I can keep a record of it. Currently, this is a shared workbook with 11 users entering information. When I review and accept or reject the changes, this wipes out the record of the changes made. Is there a way to record the changes? Any help would be greatly appreciated!

  2. #2
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Logging changes by users to a separate sheet or workbook on the same shared drive

    http://www.excel-easy.com/examples/share-workbooks.html
    do you mean that?

  3. #3
    Registered User
    Join Date
    01-19-2015
    Location
    Virginia
    MS-Off Ver
    2007
    Posts
    29

    Re: Logging changes by users to a separate sheet or workbook on the same shared drive

    tim201110: I have all of that set but once I accept / reject a change or un-protect the workbook, Excel wipes the list of changes. I'd like to keep a list of all changes, by whom, when, what etc.

  4. #4
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Logging changes by users to a separate sheet or workbook on the same shared drive

    you can do it with following code
    NB: macros must be enabled on all PCs

    [CODEVisual Basic


    Option Explicit
    Public sValue As String
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    If Sh.Name = "LOG" Then Exit Sub
    Dim sLastValue As String
    Dim lLastRow As Long, wbLOG As Workbook
    Dim sPath as String
    Const sLOGName As String = "\LOG.txt" '"\LOG.xls"
    sPath = Application.DefaultFilePath
    Application.ScreenUpdating = False
    '============== только для записи в текстовый файл ======================
    If Dir(sPath & sLOGName, vbDirectory) = "" Then
    Open sPath & sLOGName For Output As #1: Close #1
    End If
    '============== только для записи в отдельный файл Excel ======================
    ' If Dir(sPath & sLOGName, vbDirectory) = "" Then
    ' Set wbLOG = Workbooks.Add
    ' wbLOG.SaveAs sPath & sLOGName, xlNormal
    ' End If
    Set wbLOG = Workbooks.Open(sPath & sLOGName)
    '============================================================================
    With wbLOG.Sheets(1)
    lLastRow = .Cells.SpecialCells(xlLastCell).Row + 1
    If lLastRow = .Rows.Count Then Exit Sub
    Application.ScreenUpdating = False: Application.EnableEvents = False
    .Cells(lLastRow, 1) = CreateObject("wscript.network").UserName
    .Cells(lLastRow, 2) = Target.Address(0, 0)
    .Cells(lLastRow, 3) = Format(Now, "dd.mm.yyyy HH:MM:SS")
    .Cells(lLastRow, 4) = Sh.Name
    .Cells(lLastRow, 5).NumberFormat = "@"
    .Cells(lLastRow, 5) = sValue
    If Target.Count > 1 Then
    Dim rCell As Range, rRng As Range
    On Error Resume Next
    Set rRng = Intersect(Target, Sh.UsedRange): On Error GoTo 0
    If Not rRng Is Nothing Then
    For Each rCell In rRng
    If Not IsError(Target) Then sLastValue = sLastValue & "," & rCell Else sLastValue = sLastValue & "," & "Err"
    Next rCell
    sLastValue = Mid(sLastValue, 2)
    Else
    sLastValue = ""
    End If
    Else
    If Not IsError(Target) Then sLastValue = Target.Value Else sLastValue = "Err"
    End If
    .Cells(lLastRow, 6).NumberFormat = "@"
    .Cells(lLastRow, 6) = sLastValue
    End With
    wbLOG.Close 1
    Application.ScreenUpdating = True: Application.EnableEvents = True
    End Sub

    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    If Sh.Name = "LOG" Then Exit Sub
    If Target.Count > 1 Then
    Dim rCell As Range, rRng As Range
    On Error Resume Next
    Set rRng = Intersect(Target, Sh.UsedRange): On Error GoTo 0
    If rRng Is Nothing Then Exit Sub
    For Each rCell In rRng
    If Not IsError(rCell) Then sValue = sValue & "," & rCell Else sValue = sValue & "," & "Err"
    Next rCell
    sValue = Mid(sValue, 2)
    Else
    If Not IsError(Target) Then sValue = Target.Value Else sValue = "Err"
    End If
    End Sub]Please Login or Register to view this content.[/CODE]
    Last edited by tim201110; 11-05-2015 at 02:02 PM. Reason: ________________________

  5. #5
    Registered User
    Join Date
    01-19-2015
    Location
    Virginia
    MS-Off Ver
    2007
    Posts
    29

    Re: Logging changes by users to a separate sheet or workbook on the same shared drive

    tim201110: I'm entirely unfamiliar with Visual Basic. Where would I enter that and does it create a file in the same folder that the Excel file resides in? How do you turn macros on? I see Macros under the View tab but the only options are view, record or use relative references.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 08-06-2015, 10:33 AM
  2. Saving a workbook to a shared drive
    By CaptainK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2014, 01:01 PM
  3. How to check what users are in a Workbook on a shared drive?
    By btorrean in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-03-2014, 09:06 PM
  4. Shared workbook on a share drive
    By runner in forum Excel General
    Replies: 1
    Last Post: 10-27-2012, 08:39 AM
  5. Replies: 4
    Last Post: 10-21-2012, 06:00 PM
  6. Creating a Separate Logging Workbook
    By teddybouch in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2008, 12:33 PM
  7. Replies: 3
    Last Post: 02-27-2006, 01:15 PM

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