Microsoft Excel - Data Validation on formula results

Asked By pete r. on 30-Jan-14 08:46 AM
Hello

I want to use Data Validation on stock quantity numbers to bring a warning box up to advise user to order more when quantity falls below 0. 
This is straight forward to do using Whole Number option but it only works if the data is input directly into the cell.  The stock quantity is calculated by a formula from current stock level minus the allocated amount and this validation won't seem to work on the cells with formulas in.
Does this make sense to you?...  Is there a solution?

Many thanks, look forward to hearing back.
Peter
Harry Boughen replied to pete r. on 30-Jan-14 08:01 PM
Hi Pete,
One option would be to use conditional formatting to highlight the entry cell (in red fill, say) if the corresponding stock level falls below zero (or other pre-set value).
If you want a dialog box, then you will need a macro that fires when your input cell changes and displays the dialog if the stock level goes below the desired level.
The exact solution will depend on whether it is on a single cell or needed on multiple cells. 
If you can give an idea of the data layout and the cells (sungle or multiple) involved it might be possible to be more specific.
Regards
Harry
pete r. replied to Harry Boughen on 01-Feb-14 11:11 AM
Harry

Thanks for your response - the data is multiple cells in a column.  I suspect that the standard data validation function provided in excel doesn't work on formula values.  I already did the highlighting suggestion but a dialog box would be better.
I don't really want to start adding code to this workbook so I guess I'll leave it with conditional format unless anyone else knows how this might work...

Thanks
Peter
Harry Boughen replied to pete r. on 02-Feb-14 03:14 PM
Hello Pete,
The sort of code you want is not particularly onerous.  This is a simple snippet that fires when a cell in a range in column A changes and throws up a dialog box if the corresponding value in Column G goes negative as a result. 

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False
If Not Intersect(Target, Range("A2:A100")) Is Nothing Then
    If Target.Offset(0, 6).Value < 0 Then MsgBox ("Stock Level is Critical")
End If
Application.EnableEvents = True

End Sub

It has to be entered in the module for the data entry sheet.
Regards
Harry