Real quick question, hopefully:
I have a large shared workbook at my office, and part of my job is monitoring that everyone updates it regularly.
I use the following right now to monitor changes:
Option Explicit
Dim Previous As String
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Cells.Count > 1 Then Exit Sub
Previous = Target.Formula
End Sub
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sh.Name = "Log" Then Exit Sub
Application.EnableEvents = False
On Error Resume Next
With Sheets("Log").Cells(Rows.Count, 1).End(xlUp)
.Offset(1, 0).Value = Environ("UserName")
.Offset(1, 1) = Sh.Name
.Offset(1, 2) = Target.Address
.Offset(1, 3) = "'" & Target.Formula
.Offset(1, 4) = Previous
Previous = ""
.Offset(1, 5) = Now
End With
Application.EnableEvents = True
End Sub
The problem we run into right now is that the Log sheet updates in real time, so if more than one person has the workbook open while making changes, they get that irritating "Someone else has changed a cell you changed!" pop-up when they eventually go to save.
Is there a way to make the file update that log page before completing the save action, or move all of the updates down to compensate, or any sort of way I can compensate for the fact that of the dozen or so teams I'm managing at any given time at least a few of them are idiots?
Posts
I mean, there's really no way to avoid the problem you're describing. You can mitigate it by forcing users to make the log update immediately upon opening, but you would still have all the normal concurrency issues.
Like Inquisitor77 said this is usually something addressed via version control software.
However you could mock up version control by adding functions to the BeforeSave event - essentially telling it to sort out the log page before saving by comparing its log version to what is in the current master and shifting its updates to compensate. You'll need to be careful and think through exactly what you want to happen when it does this.
Steam Me
True, but I have to use the sheet mandated by our client and management, so I'm just trying to make it work.
Under normal circumstances I would just use the built-in History and Change tracking that comes with a shared Excel doc, but there are sometimes a thousand edits in a day, and sometimes it needs to be unshared briefly to update formulas and that wipes the history.
twitch.tv/Taramoor
@TaramoorPlays
Taramoor on Youtube
By the end of this thread we'll have pioneered the WSEA stack.
Hmm maybe if you can get management to budge a little, do the logging in Access? I'm pretty I've seen before where excel can insert into an access DB via an OLEDB connection
This is actually a really good idea, as long as users are only making additions to the document and aren't actually editing existing content concurrently. This way the submissions will be handled sequentially in the order they are received.
There might be ways to force the document to be locked in Shared mode as well. I'm only familiar with using the Check In/Out functionality in Sharepoint/OnePlace, but it looks like Office 365 supports it natively in Excel as well...
But if people really are making literally thousands of changes a day, that might be a huge hassle in terms of folks who accidentally check it out for long periods of time.
If I could somehow force them to save every so often it wouldn't be nearly as bad, but some people will keep the shared doc open for entire shifts before saving and updating everything.
twitch.tv/Taramoor
@TaramoorPlays
Taramoor on Youtube
You don't even need to distribute randomly in the temp sheet if you're recording usernames, just have a predefined pair of columns in the temp sheet for each username to put their {time:change} and at the end of the day run a process to amalgamate this into a single log.