If A1 is equal to 0, it will display Zero, and if it isn't equal to zero, it will display Not Zero. Change the text to what message you want it to display. If you don't want it to display anything if it isn't equal to zero, do this:
Or you can set your formula within an IF statement in the cell itself.
So if in A1 you have = your formula, change this to =If(your formula = 0, "Zero", your formula). Now you get your formula result, and "Zero" if it equals 0. Only thing is if you put a message as the TRUE part, it'll break any formulas that link to that cell for a numeric value. Unless they are IFs or similar that work off the "Zero" result message....
What do you mean by message? If you just want the message to display in a cell, reworking one of the above suggestions will work. If you want a message box to pop up, you'll need a VBA macro.
If you're working your formula in a single sheet - so A1 is your formula, say =(B1 * C1) - 10, and you're changing values in B1 and C1 to see what gives a zero, this should work. It'll run every time a cell value changes in Sheet1. Right click on sheet1, select "View code" and paste the below in.
Cheers Yogi. That's what I was looking for. If the same formula's are repeated for a number of items and appearing in a1,b1,c1 etc. is there a way of including them all in the formula or do I just have to copy it each time changing the cell letter?
Hyperion » Thu Jun 26, 2014 2:30 pm wrote:Cheers Yogi. That's what I was looking for. If the same formula's are repeated for a number of items and appearing in a1,b1,c1 etc. is there a way of including them all in the formula or do I just have to copy it each time changing the cell letter?
Highlight the cell with the formula then click the bottom right corner of the cell, and while holding the button down, drag the formula down the column and it will autofill with your formula, automatically updating the cell references for you.
Thanks Tomous, that's not what I meant. Sorry if I wasn't clear.
Private Sub Worksheet_Change(ByVal Target As Range) If Worksheets("sheet1").Range("a1") = 0 Then MsgBox "It's Zero!" End Sub
If I want it to read data from cell a1 and display a message then this is ok, but I also would like it to do the same for cell a2, a3, a4.....a100 I don't know if that can be worked in to the formula or if it has to just be c&p'd changing the cell number each time.
Private Sub Worksheet_Change(ByVal Target As Range) If Worksheets("sheet1").Range("a1") = 0 Then MsgBox "It's Zero!" End Sub
If I want it to read data from cell a1 and display a message then this is ok, but I also would like it to do the same for cell a2, a3, a4.....a100 I don't know if that can be worked in to the formula or if it has to just be c&p'd changing the cell number each time.
Maybe try changing .Range("a1") to .Range("a1:a100").
I'm not sure though as I haven't used a formula like that before.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Variant
For Each Cell In Range("a1:a10")
If Cell.Value = 0 And Cell.Value <> "" Then MsgBox "one of these is zero!" Else: End If
Next Cell
End Sub
Adding the And cell.value<> "" stops it giving the message when the cell is empty rather than zero. Every time a cell value changes it loops through the range looking for zeros. You could add an increment or .address to let you know how many/which cells = 0