I have this file that when I use it at home with my Excel 2019 everything works fine as expected, when I use it at work with Excel 365 it crashes after a few seconds. It seems to me that the problem is in the code below (in the sheet "GIACENZA MONETA"), so I'd really appreciate your help to fix it.
This code does 2 things:
- when the user changes a cell, it updates the date and time in cell F25
- when the user writes something in cell F3, it makes it upper case and adds the word "cassa " on the left (if the word "cassa" has not been written by the user).
I think there must be a conflict of some sort that makes Excel 365 crash (it just closes without any warnings this file I'm using and also other Excel files that could be open).
Private Sub Worksheet_Change(ByVal Target As Range)
Dim stringa As String
If Target.Cells.Count > 1 Then Exit Sub
On Error Resume Next
'this is actually the sheet and in F25 I write date and time of the last modification by the user
ThisWorkbook.Worksheets("GIACENZA MONETE").Range("F25").Value = "Aggiornamento giacenza: " & Format(Now(), "dd/mm/yyyy - hh:mm:ss")
'if the user writes something in F3, it becomes upper case and I write on the left the word "cassa " if it isn't already written by the user
If Not Intersect(Target, Range("F3:F3")) Is Nothing Then
Application.EnableEvents = False
Target = UCase(Target)
stringa = ThisWorkbook.Worksheets("GIACENZA MONETE").Range("F3").Value
If InStr(1, stringa, "cassa", vbTextCompare) = 0 Then
stringa = "CASSA " & stringa
ThisWorkbook.Worksheets("GIACENZA MONETE").Range("F3").Value = stringa
End If
Application.EnableEvents = True
End If
On Error GoTo 0
End Sub