Hi,
I have created table where one field (a column of 100 rows) contains data validation. If the user enters the wrong selection in one of those cells, a cell on another sheet (named "CashAdvanceErrorTrigger") calculates to TRUE (there is an error). That triggers a msgbox poping up explaining the error to the user.
Problem is that the msgbox macro runs twice when triggered. It runs normally when I remove the data validation. So, something about data validation double fires the macro.
Here's my simple code that's in the sheet where the TRUE/FALSE calculation cell is located:
Thanks for any guidance!
Lawrence
I have created table where one field (a column of 100 rows) contains data validation. If the user enters the wrong selection in one of those cells, a cell on another sheet (named "CashAdvanceErrorTrigger") calculates to TRUE (there is an error). That triggers a msgbox poping up explaining the error to the user.
Problem is that the msgbox macro runs twice when triggered. It runs normally when I remove the data validation. So, something about data validation double fires the macro.
Here's my simple code that's in the sheet where the TRUE/FALSE calculation cell is located:
Code:
Private Sub Worksheet_Calculate()
' Trigger msgbox on user entering an expense category for a cash advance
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
If Sheet4.Range("CashAdvanceErrorTrigger").Value = True Then
MsgBox "A cash advance is not an expense." & vbNewLine & vbNewLine & "For a cash advance, please select the '--'" & vbNewLine & "in the Expense Category dropdown box.", vbExclamation, "Input Error"
End If
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True
End Sub
Thanks for any guidance!
Lawrence