ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restrict Data Entry, data validation (https://www.excelbanter.com/excel-programming/357609-restrict-data-entry-data-validation.html)

Dan Connors

Restrict Data Entry, data validation
 
I have a cell that is populated through a formula, I was hoping to have an
error to display if the formula brings that cell below zero. I would also
like to cancel the event that lead up to this error.

Any ideas?

Ardus Petus

Restrict Data Entry, data validation
 
Paste following code in worksheet's code
(right-click on sheet tab, select Code)

'--------------------------
Private Sub Worksheet_Calculate()
If Range("A1").Value < 0 Then
MsgBox ("Below zero")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End Sub
'------------------------------------

HTH
--
AP


"Dan Connors" a écrit dans le message
de ...
I have a cell that is populated through a formula, I was hoping to have an
error to display if the formula brings that cell below zero. I would also
like to cancel the event that lead up to this error.

Any ideas?




Dan Connors

Restrict Data Entry, data validation
 
Fantastic! Thank you so much.

"Ardus Petus" wrote:

Paste following code in worksheet's code
(right-click on sheet tab, select Code)

'--------------------------
Private Sub Worksheet_Calculate()
If Range("A1").Value < 0 Then
MsgBox ("Below zero")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End Sub
'------------------------------------

HTH
--
AP


"Dan Connors" a écrit dans le message
de ...
I have a cell that is populated through a formula, I was hoping to have an
error to display if the formula brings that cell below zero. I would also
like to cancel the event that lead up to this error.

Any ideas?





Ardus Petus

Restrict Data Entry, data validation
 
Thanks for the feedback!
--
AP

"Dan Connors" a écrit dans le message
de ...
Fantastic! Thank you so much.

"Ardus Petus" wrote:

Paste following code in worksheet's code
(right-click on sheet tab, select Code)

'--------------------------
Private Sub Worksheet_Calculate()
If Range("A1").Value < 0 Then
MsgBox ("Below zero")
Application.EnableEvents = False
Application.Undo
Application.EnableEvents = True
End If
End Sub
'------------------------------------

HTH
--
AP


"Dan Connors" a écrit dans le

message
de ...
I have a cell that is populated through a formula, I was hoping to

have an
error to display if the formula brings that cell below zero. I would

also
like to cancel the event that lead up to this error.

Any ideas?








All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com