Search code examples
if-statementgoogle-sheetsmatchgoogle-sheets-formulavlookup

Google Sheets Formula: Map String Value in Dropdown to Number for use in Formula?


Let's say I have a cell A1 with possible dropdown values {Apple,Banana,Cherry}. The chosen string determines which constant to use in the formula for B1. What is the best way to do this in Google Sheets?


Solution

  • if {Apple,Banana,Cherry} = {1,2,3} then try:

    =MATCH(A1, {"Apple"; "Banana"; "Cherry"}, 0)
    

    or:

    =VLOOKUP(A1, {"Apple", 1; "Banana", 2; "Cherry", 3}, 2, 0)