# Solved Use If function in data validation (Excel)

May 5, 2015 at 00:01:25
Specs: Windows 7
 I wish to use the following function in value field of Data validationIF(A8="",IF(A7="",A6+1,A7+1),A8+1)I wish to allow only just next number entry in the cell with regard to entry made in previous cells whichever has value first.

See More: Use If function in data validation (Excel)

#1
May 5, 2015 at 04:52:28
 You can't use that type of formula in Data Validation. A Data Validation formula must resolve to TRUE or FALSE. See step 5 here:https://support.office.com/en-nz/ar...If you want to restrict the values in a cell to the results of the Nested IF, why not just use the IF formula in the cell and then lock the cell so the user can't alter it? In other words, just let the formula return the desired result instead of having the user enter a value.

Report •

#2
May 5, 2015 at 10:18:35
 If you do need to have the user enter a value in a cell, I think that this Data Validation workaround will work.I don't believe that you can use a Nested IF in Data Validation since the first FALSE it encounters will trigger the Data Validation message, even if the overall IF statement eventually resolves to TRUE. So we need to use an simple IF function in the Data Validation wizard, one that only has a single logical_test.This workaround will require a Helper Cell, e.g. A1Let's say the user-entry cell that you want to validate is A9. Put this formula in A1:```=IF(AND(A8<>"",A9=A8+1),1, IF(AND(A8="",A7<>"",A9=A7+1),1, IF(AND(A8="",A7="",A9=A6+1),1,0)))```This will put a 1 or 0 in A1 if the conditions you asked for are met.Now, select Data Validation...Custom for A9 and use this formula:=A1=1When the Nested IF in A1 resolves to 1, the Data Validation will be TRUE and the value will be allowed.Let us know if that works for you.