Steeven
Steeven

Reputation: 4200

Iterate through all cells in a column instead of checking all cells individually

I have a simple list with labels and values in a Google Spreadsheet. Below, I have some fields in which I would like to get the value when writing the label.

enter image description here

For example, if I write D in a cell, I want the next cell to show 4, the value corresponding to D.

This can of course be done with repetitive IFs inside IFs inside IFs... in cell B8, like this:

=IF(A8=A1;B1; IF(A8=A2;B2; IF(A8=A3;B3; IF(A8=A4;B4; IF(A8=A5;B5;0)))))

This simply checks row by row: If the written value matches the label of row 1, then show the value. If not, then perform a new IF command on the second row. Etc.

With many rows this is quite tedious. Is it possible in Google Spreadsheets to simplify this a bit? For instance, can I in some way collect all cells in a column in one IF statement by doing A1:A5 or something like that? Something along the lines of:

=IF(A8=A1:A5;B1:B5;0)

Upvotes: 1

Views: 29

Answers (1)

player0
player0

Reputation: 1

solve it by using simple VLOOKUP:

=VLOOKUP(A8, A1:B5, 2, 0)

0

Upvotes: 1

Related Questions