Forum Discussion
VBA events stop working for one user when another user opens the shared workbook
Hi,
I’m experiencing a strange issue with VBA in Excel.
We use several Excel files as a CRM system, all with VBA (mainly worksheet events). The files are shared so that my employee and I can work on them.
Recently, VBA events stopped working only on my computer in some of the files.
Important observations:
For my employee, everything works normally.
Manual macros run correctly on my machine.
Worksheet events (like Worksheet_Change) do not fire.
Application.EnableEvents returns True.
Macro security and Trusted Locations are already configured.
The files are almost identical (same structure and VBA code).
What makes it even stranger:
A file that worked for me yesterday stopped working today immediately after my employee opened it.
Since then, the VBA events no longer trigger on my computer in that file, while they still work perfectly for him.
So it seems that when another user opens the shared workbook, VBA events stop working only on my machine.
Has anyone seen something like this before?
Thanks.
1 Reply
- NikolinoDEPlatinum Contributor
Based on your detailed description, this appears to be a known limitation in Excel's shared workbook functionality when combined with VBA events. Is a classic symptom of Excel's legacy shared workbook architecture, and your diagnostic work is excellent.
You've correctly identified the core issue: when a workbook enters legacy shared mode (Review > Share Workbook), Excel forcibly disables all VBA events at the engine level. This is by design, not a bug. Microsoft implemented this to prevent data corruption that could occur if multiple users triggered simultaneous event-driven code.
Key points from your observations that confirm this:
- Application.EnableEvents returns True but events don't fire (Excel overrides this setting in shared mode)
- Manual macros work perfectly (they don't rely on automatic triggers)
- The issue started precisely when a second user opened the file (the moment it became shared)
When your employee opens the file, Excel transitions it into shared mode. From that moment forward:
- Your session: Events are disabled at the C++ level, regardless of VBA settings
- Employee's session: Same limitation applies to them
- The file appears to work for them because they likely haven't tested events while you're both in the file, or they're using different functionality.
While we cannot override Excel's fundamental architecture, here are a approach that provide partial functionality:
Workaround with a switch…
This is the most practical because it:
- Requires zero changes to existing CRM logic
- Automatically detects when to use events vs buttons
- Takes 5 minutes to implement
- Works immediately for both users
' ============================================= ' SMART CRM SWITCH - PASTE IN THISWORKBOOK MODULE ' ============================================= Private Sub Workbook_Open() ' CRITICAL: Check shared status immediately If ThisWorkbook.MultiUserEditing Then ' We're in shared mode - events disabled, switch to button mode Call EnableButtonMode Else ' Exclusive mode - events work perfectly Call EnableEventMode End If End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) ' Prevent accidental saving in wrong mode Static lastWarning As Date If ThisWorkbook.MultiUserEditing Then ' In shared mode - that's fine, just warn about events If DateDiff("s", lastWarning, Now) > 300 Then ' Every 5 minutes MsgBox "Reminder: You're in shared mode." & vbCrLf & _ "• Use the CRM toolbar buttons for updates" & vbCrLf & _ "• Automatic events are disabled", _ vbInformation, "CRM System" lastWarning = Now End If End If End Sub ' ============================================= ' MODE MANAGEMENT ' ============================================= Private Sub EnableButtonMode() ' Show toolbar for manual operations Call CreateCrmToolbar(True) ' Notify user ONCE per session Static notified As Boolean If Not notified Then MsgBox "CRM: MULTI-USER MODE ACTIVE" & vbCrLf & _ "• Multiple people can edit simultaneously" & vbCrLf & _ "• Please use the CRM toolbar (top of screen)" & vbCrLf & _ "• Automatic updates are temporarily disabled", _ vbInformation, "CRM System" notified = True End If End Sub Private Sub EnableEventMode() ' Hide toolbar, use automatic events Call CreateCrmToolbar(False) ' Ensure events are enabled Application.EnableEvents = True ' Brief confirmation (optional) ' Debug.Print "Exclusive mode - events active at " & Now End Sub ' ============================================= ' CRM TOOLBAR (YOUR BUTTON INTERFACE) ' ============================================= Private Sub CreateCrmToolbar(ShowIt As Boolean) On Error Resume Next ' Remove existing toolbar if any Application.CommandBars("CRM Tools").Delete On Error GoTo 0 If Not ShowIt Then Exit Sub ' Create new toolbar Dim cb As CommandBar Set cb = Application.CommandBars.Add("CRM Tools", msoBarTop, Temporary:=True) ' Add your CRM buttons (customize these!) With cb.Controls.Add(msoControlButton) .Caption = "Add Customer" .FaceId = 211 .OnAction = "CRM_AddCustomer" .TooltipText = "Add new customer record" .Style = msoButtonIconAndCaption End With With cb.Controls.Add(msoControlButton) .Caption = "Edit Customer" .FaceId = 213 .OnAction = "CRM_EditCustomer" .TooltipText = "Edit selected customer" .Style = msoButtonIconAndCaption End With With cb.Controls.Add(msoControlButton) .Caption = "View All" .FaceId = 215 .OnAction = "CRM_ViewAll" .TooltipText = "View all customers" .Style = msoButtonIconAndCaption End With With cb.Controls.Add(msoControlButton) .Caption = "Reports" .FaceId = 217 .OnAction = "CRM_Reports" .TooltipText = "Generate reports" .Style = msoButtonIconAndCaption End With cb.Visible = True End Sub ' ============================================= ' YOUR EXISTING CRM CODE (ADAPTED FOR BUTTONS) ' ============================================= ' These subs should contain your existing Worksheet_Change logic ' Just moved to button-triggered operations Public Sub CRM_AddCustomer() ' PASTE YOUR EXISTING "ADD CUSTOMER" CODE HERE ' This is whatever you normally do when adding a customer ' Example: Dim newRow As Long newRow = Sheets("Customers").Range("A" & Rows.Count).End(xlUp).Row + 1 ' Simple input form Dim custName As String custName = InputBox("Enter customer name:", "Add Customer") If custName <> "" Then Sheets("Customers").Cells(newRow, 1) = custName Sheets("Customers").Cells(newRow, 2) = Date Sheets("Customers").Cells(newRow, 3) = Environ("Username") MsgBox "Customer added successfully!", vbInformation End If End Sub Public Sub CRM_EditCustomer() ' PASTE YOUR EXISTING "EDIT CUSTOMER" CODE HERE Dim rng As Range Set rng = Selection If rng.Cells.Count > 1 Then MsgBox "Please select a single customer cell.", vbExclamation Exit Sub End If If rng.Row < 2 Then MsgBox "Please select a customer row.", vbExclamation Exit Sub End If ' Your edit logic here Dim newValue As String newValue = InputBox("Enter new value:", "Edit Customer", rng.Value) If newValue <> "" Then rng.Value = newValue MsgBox "Customer updated!", vbInformation End If End Sub Public Sub CRM_ViewAll() ' PASTE YOUR EXISTING "VIEW" CODE HERE Sheets("Customers").Activate Range("A1").Select End Sub Public Sub CRM_Reports() ' PASTE YOUR EXISTING "REPORTS" CODE HERE MsgBox "Generating CRM reports..." & vbCrLf & _ "This feature will be available in the next update.", _ vbInformation, "Reports" End Sub ' ============================================= ' KEEP YOUR EXISTING EVENT CODE (IT STILL WORKS IN EXCLUSIVE MODE!) ' ============================================= ' Your original Worksheet_Change events remain exactly as they are ' They'll fire automatically when you're in exclusive mode ' They'll be safely ignored in shared mode (no errors, just won't fire) Private Sub Worksheet_Change(ByVal Target As Range) ' YOUR ORIGINAL EVENT CODE - UNCHANGED ' This automatically runs when you're the only user ' Does nothing in shared mode (Excel disables it) ' Example - replace with your actual CRM logic If Not Intersect(Target, Range("A:A")) Is Nothing Then If Target.Row > 1 Then ' Auto-timestamp when customer name changes Target.Offset(0, 1).Value = Date Target.Offset(0, 2).Value = Environ("Username") End If End If End SubInstallation Instructions
Step 1: Open your CRM file
Step 2: Press Alt + F11 to open VBA
Step 3: Double-click "ThisWorkbook" in Project Explorer
Step 4: Paste the ENTIRE code above
Step 5: Press Ctrl + S to save
Step 6: Close and reopen the fileWhat This Gives...
Mode
When
Events
Toolbar
Works?
Exclusive
Just for you in file
Automatic
Hidden
Perfect
Shared
Both users
Disabled
Visible
Reliable
The One-Minute User Training
CRM Quick Guide:
- Blue toolbar at top? = Multiple users editing. Click buttons to update CRM.
- No toolbar? = You're alone. Automatic updates work like always.
- Simple rule: See toolbar → use buttons. No toolbar → type normally.
Look, I know you want your automatic events back. But here's the reality: Excel was never designed to have two people triggering VBA events simultaneously in the same file. It's like two drivers both trying to control the same car.
My answers are voluntary and without guarantee!
Hope this will help you.
Was the answer useful? Mark as best response and like it!
This will help all forum participants.