![]() |
Simple request
How do you get a message box to appear when a cell is 0.
I have a simple function that has values and I want a message box (with a warning)to appear when the cell is equal to zero. Exel VB newbie |
Simple request
'-----------------------------------------------------------------
Private Sub Worksheet_Change(ByVal Target As Range) '----------------------------------------------------------------- Const WS_RANGE As String = "H10" On Error GoTo ws_exit: Application.EnableEvents = False If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then If Target.Value = 0 MsgBox "tell me something" End If End If ws_exit: Application.EnableEvents = True End Sub 'This is worksheet event code, which means that it needs to be 'placed in the appropriate worksheet code module, not a standard 'code module. To do this, right-click on the sheet tab, select 'the View Code option from the menu, and paste the code in. -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Johnmayo" wrote in message ... How do you get a message box to appear when a cell is 0. I have a simple function that has values and I want a message box (with a warning)to appear when the cell is equal to zero. Exel VB newbie |
Simple request
"Johnmayo" wrote in message
... How do you get a message box to appear when a cell is 0. I have a simple function that has values and I want a message box (with a warning)to appear when the cell is equal to zero. In addition to Bob's VBA solution, you can do this with Excel's Data Validation featu 1) Choose Data Validation from the Excel menu. 2) In the Settings tab select "Custom" from the Allow dropdown. 3) Enter the following formula in the Formula box, substituting the address of your cell for $A$1: =$A$1<0 4) Select the Error Alert tab 5) Select "Information" from the Style dropdown, then enter a message box title and a message in the two other controls. -- Rob Bovey, Excel MVP Application Professionals http://www.appspro.com/ * Take your Excel development skills to the next level. * Professional Excel Development http://www.appspro.com/Books/Books.htm |
All times are GMT +1. The time now is 02:40 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com