I have several macros and they work perfectly on my computer (HP I5 with 8 GB of RAM), but in some macros that use the Worksheet_Change event, it closes Excel.
I took a file from scratch and created a test with a very simple code, where it generates a function to send a msgbox when a cell value is modified.
If I put a button to execute the function, it works perfect.
IF I put the function call through Worksheet_Change of the cell where the value changes, when I execute it, Excel automatically closes.
This is the function (Module1).
Sub Message_Age()
If Sheets("Sheet1").Range("E3") >= 18 Then
MsgBox "Hello " & Sheets("Sheet1").Range("D3")
Else
MsgBox "You are a minor " & Sheets("Sheet1").Range("D3")
End If
End Sub
When I want to run automatically when cell “E3” is changed, if I change the value it closes the Excel.
Here the code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$E$3" Then
Call Message_Age
End If
End Sub
My work computer is a Notebook with Windows 10 and Excel 2007.
Your help please.
Thank you
Greetings
Cristian
Excel closes immediately and no message appears.
If I only set the procedure to empty, the same thing happens, Excel closes.
Private Sub Worksheet_Change(ByVal Target As Range)
'
'
End Sub
Cristian Vildosola is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.