ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   IF Statement accepting only positive values (https://www.excelbanter.com/excel-discussion-misc-queries/449557-if-statement-accepting-only-positive-values.html)

Ada33

IF Statement accepting only positive values
 
Hi guys,

I assume this is going to have to be done through data validation.

In column A, I have text in cells A1:A10, in column B, I want to put in a formula saying "If A1 contains 'test text', then only accept a positive number" and return an error if a negative number is attempted to be typed in. How do I do this?

Thanks,
Amin

zvkmpw

IF Statement accepting only positive values
 
In column A, I have text in cells A1:A10, in column B, I want to put in
a formula saying "If A1 contains 'test text', then only accept a
positive number" and return an error if a negative number is attempted
to be typed in. How do I do this?


Select column B and in
Data Data tools Data Validation Settings
put

Allow:
Custom

Formula:
=OR(A1<"test text", B10)
(The post doesn't say what to do if zero is entered in column B.
The formula assumes it's lumped in with the negative; if not,
change "B10" to "B1=0")

Then click the "Error Alert" tab and enter the desired error message.

Finally, click "OK"

Hope this helps getting started.


All times are GMT +1. The time now is 03:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com