+ Reply to Thread
Results 1 to 17 of 17

Track changes within a workbook without sharing the workbook

Hybrid View

  1. #1
    Registered User
    Join Date
    11-08-2017
    Location
    Springfield, MO
    MS-Off Ver
    2013
    Posts
    7

    Track changes within a workbook without sharing the workbook

    Looking to track changes on a separate tab in a workbook without placing the workbook as a "Shared Workbook". I have heard the best way would be to use a VBA Event Handler. I am not good with code, I could understand it by reverse engineering it if I had some idea of what the code meant in relation to the tabs.
    Thanks

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,446

    Re: Track changes within a workbook without sharing the workbook

    .
    Paste this code in the ThisWorkbook module :

    Dim vOldVal 'Must be at top of module
    
    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Dim strUserName As String
    Dim xFormula As Boolean
    Dim xDate As Boolean
    Dim xHead As Range
    Dim xTitle As Range
    
    Set xHead = Sheets("Track_Changes").Range("B3:H3")
    strUserName = Application.UserName
    
    On Error Resume Next
    If Target.Cells.Count > 1 Then Exit Sub
    On Error Resume Next
        
    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With
        
        If IsEmpty(vOldVal) Then vOldVal = "[empty cell]"
        xFormula = Target.HasFormula
        xDate = IsDate(Target)
    
        With Sheets("Track_Changes")
            .Unprotect Password:="Password"
           
                    If .Range("B2") = vbNullString Then
                        xHead = Array("DATE OF CHANGE", "TIME OF CHANGE", "SHEET NAME", "CELL CHANGED", "CHANGE BY", "OLD VALUE", "NEW VALUE")
                    Sheets("Track_Changes").Columns(1).ColumnWidth = 3
                    
                    .Range("B1").Value = "Track Changes"
                    .Range("B1").Font.Size = 18
                                    
                    With xHead
                        .Interior.Color = RGB(30, 139, 195)
                        .Font.Color = vbWhite
                        .Font.Bold = True
                    End With
    
                    With xHead.Borders(xlInsideVertical)
                        .Color = vbWhite
                        .Weight = xlMedium
                    End With
                    End If
                
            
            With .Cells(.Rows.Count, 2).End(xlUp)(2, 1)
                        .Borders(xlInsideVertical).Color = RGB(255, 191, 191)
                        .Borders(xlInsideVertical).Weight = xlMedium
                        
                        .Value = Date
                        .Offset(0, 1) = Format(Now, "hh:mm:ss")
                        .Offset(0, 2) = Target.Parent.Name
                        .Offset(0, 3) = Target.Address
                        .Offset(0, 4) = strUserName
                        .Offset(0, 5) = vOldVal
                      
                        With .Offset(0, 6)
                            If xFormula = True Then
                                .ClearComments
                                .AddComment.Text Text:="Cell is bold as value contains a formula"
                            End If
                            If xDate = True Then
                                .NumberFormat = "dd/mm/yyyy"
                            End If
                            .Value = Target
                            .Font.Bold = xFormula
                            If IsEmpty(Target) Then .Value = "[empty cell]"
                        End With
                        
                End With
    
                .Cells.Columns.AutoFit
                .Cells.Columns.HorizontalAlignment = xlLeft
                
    n = Sheets("Track_Changes").Range("B:B").Cells.SpecialCells(xlCellTypeConstants).Count - 1
    With Sheets("Track_Changes").Range("B4:H" & n + 2)
            .Borders(xlInsideHorizontal).Color = RGB(30, 139, 195)
            .Borders(xlInsideHorizontal).Weight = xlThin
            .Borders(xlInsideVertical).Color = RGB(200, 200, 200)
            .Borders(xlInsideVertical).Weight = xlThin
    End With
    .Protect Password:="Password"
            End With
        vOldVal = vbNullString
    
        With Application
             .ScreenUpdating = True
             .EnableEvents = True
        End With
    
    On Error GoTo 0
    
    End Sub
    
    
    
    Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    
    On Error Resume Next
    If Selection.Cells.Count > 1 Then Exit Sub 'Avoid runtime error 7
        vOldVal = Target
    
    End Sub
    You can hide the TRACKER sheet, which is password protected, so only you have access.
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    11-08-2017
    Location
    Springfield, MO
    MS-Off Ver
    2013
    Posts
    7

    Re: Track changes within a workbook without sharing the workbook

    Hi Logit,
    Thanks for your help. I did not see your response until today when I came back to work. I will attempt this but do you have the password to the protected sheet. I attempted to view the code on this sheet and cannot see it. Is that because it is protected?

    Thanks again.

  4. #4
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Re: Track changes within a workbook without sharing the workbook

    Hi Logit, Do you know a way to add computer name or host name?

    Thanks,

    Madison

  5. #5
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,446

    Re: Track changes within a workbook without sharing the workbook

    .
    I added the 'Environ' command here :

    .Value = Date
                        .Offset(0, 1) = Format(Now, "hh:mm:ss")
                        .Offset(0, 2) = Target.Parent.Name
                        .Offset(0, 3) = Target.Address
                        .Offset(0, 4) = strUserName
                        .Offset(0, 5) = vOldVal
                        .Offset(0, 7) = Environ("username") 
    Attached Files Attached Files

  6. #6
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Re: Track changes within a workbook without sharing the workbook

    Thanks Logit. I changed it to "ComputerName". This is the best tracking code I have ever seen.

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,446

    Re: Track changes within a workbook without sharing the workbook

    .
    You are welcome.

    I agree ... it's a pretty nifty project. Can't claim credit for most of it though ... got most of it from somewhere.

    Cheers.

    ps: Be certain to change the wording in the Macro as well for "ComputerName"

    If .Range("B2") = vbNullString Then
                        xHead = Array("DATE OF CHANGE", "TIME OF CHANGE", "SHEET NAME", "CELL CHANGED", "CHANGE BY", "OLD VALUE", "NEW VALUE", "COMPUTERNAME")
                    Sheets("Track_Changes").Columns(1).ColumnWidth = 3

  8. #8
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,446

    Re: Track changes within a workbook without sharing the workbook

    .
    The code is on the ThisWorkbook module. Once you get into the VBE, doubleclick on ThisWorkbook. The project does not have a password.

  9. #9
    Registered User
    Join Date
    11-08-2017
    Location
    Springfield, MO
    MS-Off Ver
    2013
    Posts
    7

    Re: Track changes within a workbook without sharing the workbook

    Logit,
    I wanted to say thank you for your help on this. It is working great, there are few things that it will not track but at this time it is working and I am happy with the results. It auto saves after every entry and will not let you undo it.

    Thank you for your time.

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,446

    Re: Track changes within a workbook without sharing the workbook

    .
    What is it not tracking ? I haven't noticed that here. Curious.

  11. #11
    Registered User
    Join Date
    11-08-2017
    Location
    Springfield, MO
    MS-Off Ver
    2013
    Posts
    7

    Re: Track changes within a workbook without sharing the workbook

    Does not track when you autofill down.(Number Sequence)
    Does not track when you insert or delete rows or columns.
    Does not track merged cells old value.
    Does not track copy & paste to multiple cells, only one at a time.
    Sometimes you may have double click the cell then press enter for it to acknowledge the change.
    Hope this helps.

  12. #12
    Forum Contributor
    Join Date
    06-26-2013
    Location
    LAX
    MS-Off Ver
    Excel 2007,Excel 2010
    Posts
    363

    Re: Track changes within a workbook without sharing the workbook

    Hello @logit, I was trying to use your file - Track Changes Log - xlsx sheet.xlsm‎ and I want to delete the data from the Track changes sheet.. But while trying to delete its asking for a password. Is it password protected?

  13. #13
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,446

    Re: Track changes within a workbook without sharing the workbook

    .
    No passwords. I don't understand why that is happening for others.

    Here is the file again. Hopefully it won't cause any issues :
    Attached Files Attached Files

  14. #14
    Forum Contributor
    Join Date
    06-26-2013
    Location
    LAX
    MS-Off Ver
    Excel 2007,Excel 2010
    Posts
    363

    Re: Track changes within a workbook without sharing the workbook

    Hi

    Thanks for uploading.
    Unprotect Password:="Password"
    found the password

    Thanks for the code, so helpful to begin with solving my problem.

  15. #15
    Registered User
    Join Date
    04-09-2019
    Location
    Columbus, OH
    MS-Off Ver
    2010
    Posts
    5

    Re: Track changes within a workbook without sharing the workbook

    Hi
    Thanks for sharing this! It was perfect for what I'm working on.

    Is there a way to have it not track changes for certain sheets?

  16. #16
    Registered User
    Join Date
    06-11-2019
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    2

    Re: Track changes within a workbook without sharing the workbook

    Hi,
    Great code! But if I want it to show the old value on merged cells, how do I do this?

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,049

    Re: Track changes within a workbook without sharing the workbook

    Quote Originally Posted by anjalr93 View Post
    Hi,
    Great code! But if I want it to show the old value on merged cells, how do I do this?
    Administrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original. Please start a new thread - See Forum rule #4

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

+ 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. Track Changes without sharing the workbook
    By Cameronl in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-11-2017, 02:55 AM
  2. Replies: 4
    Last Post: 11-10-2017, 02:08 PM
  3. Replies: 4
    Last Post: 09-05-2015, 08:41 PM
  4. Sharing a Workbook with with connections to another workbook
    By mmanning in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-22-2015, 04:53 PM
  5. Track changes without sharing workbook
    By naomi in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 02-04-2008, 04:29 PM
  6. Replies: 1
    Last Post: 12-16-2006, 04:23 PM
  7. sharing a workbook
    By mprible in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 11:05 AM

Tags for this Thread

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