Message Box popup if cell is negative

jrisebo

Active Member
Joined
Mar 15, 2011
Messages
321
Office Version
  1. 365
Platform
  1. Windows
Im trying to get some code to work for a range of cells being negative. Lets say A1 to A5 are the cells to check, I want a message box to pop up saying "Hey, one of your values is negative" The values wont be data entry, but a cell that is calculated based on some other entry.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
VBA Code:
Sub FFF()
  If Application.Min([A1:A5]) < 0 Then MsgBox "One of the values is negative", vbExclamation
End Sub
 
Upvote 0
Thanks this worked.

Anyway to only get it to show up once per opening of the file, i.e. "disable until nextime I open file" checkbox?
 
Upvote 0
Place in ThisWorkbook code module. - Copied from @Sektor
VBA Code:
Private Sub Workbook_Open()
 If Application.Min([A1:A5]) < 0 Then MsgBox "One of the values is negative", vbExclamation
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,577
Messages
6,173,164
Members
452,504
Latest member
frankkeith2233

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top