Search code examples
if-statementgoogle-sheetsarray-formulas

ARRAYFORMULA Enter data if relevant but allow user input if not


I want a table to auto-fill if we have the data to input but allow user input if not. I've tried using an ARRAYFORMULA but if the user enters data into an empty field, the formula breaks.

Example:

    A     B     C
1|Date Policy *This cell contains formula below*
2| 1/1  High  6 Days
3| 2/1  Med   4 Days  
4| 3/1        
5| 4/1  Low   2 Days

=ARRAYFORMULA(IF(B2:B5="High","6 Days",IF(B2:B5="Med","4 Days",IF(B2:B5="Low","2 Days",""))))

I want the user to be able to input their own data in cell C4 (and B4) without it affecting the arrayformula

The empty row could be anywhere, it wont always be row 4


Solution

  • this is certainly not an exact answer to your question, but this solution allows you to do without using scripts - the user can enter data in another column (here column D) on this line, and the formula will search the result in B and if it is empty, then in D

    =ArrayFormula(IFNA(VLOOKUP(B2:B5,G1:H3,2,false),VLOOKUP(D2:D5,G1:H3,2,false)))

    enter image description here