Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Request for VB to do something simple (insert text in a column ofcells) David Nebenzahl Excel Discussion (Misc queries) 5 November 21st 07 04:24 AM
Here is a simple formula request from a newb Darryl Excel Worksheet Functions 5 July 27th 06 08:51 PM
Simple line fix request. sungen99[_37_] Excel Programming 4 January 25th 06 04:45 PM
DATEDIF Simple request TAS-LGS Excel Worksheet Functions 1 October 26th 05 01:30 PM
CF in VB Code - Simple Request Kevin Baker[_2_] Excel Programming 2 May 2nd 05 12:34 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"