Hello Everyone,
I am very new to Mr.Excel message board and looking for some help with VBA since i am new to this as well. I created two events a change and a calculate as per below. the issue i am getting a method"Undo of Object'_ application failed error. the weird thing is that this error goes away if i delete / remove the calculate event ! or to be more specific if i remove the else Waterbblperbbl.ClearComments in the calculate event, then the change event code would work perfectly. i do not understand why the two events are incompatible? i need to have the two events in my sheet. Could anyone help?
I am very new to Mr.Excel message board and looking for some help with VBA since i am new to this as well. I created two events a change and a calculate as per below. the issue i am getting a method"Undo of Object'_ application failed error. the weird thing is that this error goes away if i delete / remove the calculate event ! or to be more specific if i remove the else Waterbblperbbl.ClearComments in the calculate event, then the change event code would work perfectly. i do not understand why the two events are incompatible? i need to have the two events in my sheet. Could anyone help?
VBA Code:
Private Sub Worksheet_Calculate()
Dim Waterbblperbbl As Range
Set Waterbblperbbl = Range("F22")
If Waterbblperbbl > 0 Then
Waterbblperbbl.ClearComments
Waterbblperbbl.AddComment ("bbl of water per 1 bbl of mud")
Else
Waterbblperbbl.ClearComments
End If
End sub
the second event is a change one as follow:
If Target.Address = Range("$D$15").Address Then
Range("$F$15").ClearContents
End If
If Target.Address = "$AJ$3" Then
If Range("AJ3").Value <> Sheet4.Range("E7") Then
Application.Undo
MsgBox "This cell content cannot be changed"
End If
End If
Last edited by a moderator: