Try this:
=iferror(vlookup(C2,Sheet2!A$1:B$6,2,FALSE),"")
Here's an example.
Some notes:
- Put the formula in the cell you want to fill
- C2 refers to the value you're using to look up in the array
- When entering the array range, make sure to put in
$
before the row numbers, otherwise the range will be dynamic, not fixed.
- If you add more categories, you'll need to update the formula on Sheet1
Older post, but I wrote a single-cell array formula that accomplishes this task and placed it into your editable sheet, in a new sheet I created for the purpose (Sheet2).
Headers are manually entered in Sheet2!A1:E1.
The following array formula is entered into Sheet2!A2:
=ArrayFormula(IF(ROW(Sheet1!A2:A)>COUNTA(Sheet1!A2:A)*18+1,"",{VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),VLOOKUP(VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),Sheet1!A2:AM,{2,3},FALSE),VLOOKUP(VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),Sheet1!A2:AM,MOD(ROW(Sheet1!A2:A)-2,18)+4,FALSE),VLOOKUP(VLOOKUP(Sheet1!A$1,TRANSPOSE(QUERY({Sheet1!A:AM})),INT((ROW(Sheet1!A2:A)-2)/18)+2,FALSE),Sheet1!A2:AM,MOD(ROW(Sheet1!A2:A)-2,18)+22,FALSE)}))
Best Answer
This is a known bug in new Sheets whereby the spreadsheet regional settings generate an incorrect output. From the entry on this duplicate issue ticket:
[For Google Apps Script questions you may get a better response in Stackoverflow]