I'm currently developing my Excel workbook on a Core i7 laptop. I've sent my Excel file to colleagues on MS Surface tablets. These colleagues are getting different behaviours on the Surfaces.
The steps were to: open the Excel file, switch to a tab and send me a log file written in %appdata%.
The tab in question has the following code:
Option Explicit
Private Sub Worksheet_Activate()
If p Is Nothing Then Set p = New Projects
p.validateSheet
End Sub
Private Sub Worksheet_Change(ByVal target As Excel.Range)
If p Is Nothing Then Set p = New Projects
p.updateSheet target
End Sub
Essentially, from my log file, when the laptop switches to the tab it calls Worksheet_Activate. However, the Surfaces are calling Worksheet_Change for each row and cells in the worksheet.
I've confirmed, the Office version is the same in both instances.
Any ideas why this is happening?
Edit #1
Part of the log that was returned. Note "Starting" and "Ending" of updateSheet, and the range changing.
2020-10-13 9:53:08 AM: Starting updateSheet.
2020-10-13 9:53:08 AM: Range: $D$2
2020-10-13 9:53:08 AM: 0001
2020-10-13 9:53:08 AM: Reset credentialWindowCancelled.
2020-10-13 9:53:08 AM: Ending updateSheet.
2020-10-13 9:53:08 AM: Starting updateSheet.
2020-10-13 9:53:08 AM: Range: $E$2
2020-10-13 9:53:08 AM: 0001
2020-10-13 9:53:08 AM: Reset credentialWindowCancelled.
2020-10-13 9:53:08 AM: Ending updateSheet.
2020-10-13 9:53:08 AM: Starting updateSheet.
2020-10-13 9:53:08 AM: Range: $F$2
2020-10-13 9:53:08 AM: 0001
2020-10-13 9:53:08 AM: Reset credentialWindowCancelled.
2020-10-13 9:53:08 AM: Ending updateSheet.
2020-10-13 9:53:08 AM: Starting updateSheet.
2020-10-13 9:53:08 AM: Range: $G$2
2020-10-13 9:53:08 AM: 0001
2020-10-13 9:53:08 AM: Reset credentialWindowCancelled.
2020-10-13 9:53:08 AM: Ending updateSheet.
2020-10-13 9:53:08 AM: Starting updateSheet.
2020-10-13 9:53:08 AM: Range: $H$2
2020-10-13 9:53:08 AM: 0001
2020-10-13 9:53:08 AM: Reset credentialWindowCancelled.
2020-10-13 9:53:08 AM: Ending updateSheet.
Edit #2
How p is initialized in ThisWorkbook code:
Private Sub Workbook_Open()
...
Set p = New Projects
...
End Sub
Update #1
The following code, run on my colleagues tablet, kept displaying Worksheet_Activate...
Option Explicit
Private Sub Worksheet_Activate()
Debug.Print Now() & ": " & "Worksheet_Activate"
End Sub
Private Sub Worksheet_Change(ByVal target As Excel.Range)
Debug.Print Now() & ": " & "Worksheet_Change"
End Sub
I went back to my logs and found this (truncated to illustrate my point)
2020-10-13 12:51:06 PM: Starting validateSheet.
2020-10-13 12:51:06 PM: Starting FetchIdentification
2020-10-13 12:51:06 PM: Starting sendBitsRequest
...
2020-10-13 12:51:21 PM: Ending sendBitsRequest
2020-10-13 12:51:22 PM: Starting updateSheet.
...
2020-10-13 12:51:35 PM: Ending validateSheet.
Notice "Starting validateSheet" called from Worksheet_Activate and "Starting updateSheet" called from Worksheet_Change. No "Ending validateSheet" nearby either.
There seems to be a transition from Worksheet_Activate to Worksheet_Change...
Also noting, only my machine seems to run this code properly. I was able to replicate on tablets and other laptops. So, all on me apparently.
p is being initialized in a file located under Modules. It's not being instantiated anywhere, however:
Public p As New Projects