M
Matthew Pfluger
I'm trying to write advanced Data Validation using VBA instead of the
built-in Data Validation because I need a dependent cell to change its value
if an independent cell's value changes (the whole dependent list problem
again). I'm using Worksheet_Change to accomplish this. However, the
following code gives me an error.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo 0
Stop
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Range("inpSplineFit").value = "FILLET ROOT SIDE FIT"
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
end sub
Range("inpSplineFit") = Cell B5, and the name is valid and not the cause of
the problem. The only way to get the error code is to step through the code
because it doesn't display any message by itself. It just errors out and
keeps moving, despite the error handling. The error is 40040,
Application-defined or object-defined error. The worksheet is not protected.
Even more strangely, the exact same code works when used in
Worksheet_SelectionChange.
I've tried deleting the sheet and starting over. I've tried cleaning the
project with Code Cleaner, and nothing works. What is going on?
Thanks,
Matthew Pfluger
built-in Data Validation because I need a dependent cell to change its value
if an independent cell's value changes (the whole dependent list problem
again). I'm using Worksheet_Change to accomplish this. However, the
following code gives me an error.
Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo 0
Stop
Application.Calculation = xlCalculationManual
Application.EnableEvents = False
Range("inpSplineFit").value = "FILLET ROOT SIDE FIT"
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
end sub
Range("inpSplineFit") = Cell B5, and the name is valid and not the cause of
the problem. The only way to get the error code is to step through the code
because it doesn't display any message by itself. It just errors out and
keeps moving, despite the error handling. The error is 40040,
Application-defined or object-defined error. The worksheet is not protected.
Even more strangely, the exact same code works when used in
Worksheet_SelectionChange.
I've tried deleting the sheet and starting over. I've tried cleaning the
project with Code Cleaner, and nothing works. What is going on?
Thanks,
Matthew Pfluger