Alright, the title is a hair misleading. First, I'm in Google Spreadsheet. Second, This more than a IF(condition, return IF(...)) kind of situation (Also, I was looking around to see if I could even post an excel formula question on this site... didn't see much so if this is not the proper place feel free to say so and I'll delete).
I have a table that I need to get a value from based on 2 cells:
-3 -2 -1 0 1 2 3 4 5
___________________________
A| 0, 0, 0, 1, 2, 4, 8, 12,16
B| 0, 0, 1, 2, 4, 8, 12,16,20
C| 0, 1, 2, 4, 8, 12,16,20,24
D| 1, 2, 4, 8, 12,16,20,24,28
I basically need C1 to equal what would be returned if A1 was "A", "B", "C", or "D" , and B1 was in the range of -3 - 5.
All of my attempts have been #error, so I don't have anything to show for the last hour I've put into figuring this out. I'm confident there's a way though. If you want my failed attempts let me know.
You can use
VLOOKUP
. For example, if you place the table at A5, make the following the formula forC1
:(
A5:J9
is your lookup table; you can move it wherever, even on another sheet)Try using
INDEX
in array mode:Assuming
data is in
$G$9:$O$12
row labels (
A
..D
) is in$F$9:$F$12
column labels in
$G$8:$O$8
This has the advantage that it does not rely on the column headers being integers in ascending order.
Suppose that your table is stored on the top left of
Sheet2
, then you can use the following formula in cellC1
:The
VLOOKUP
function looks up the row where your desired letter is (as given inA1
). If it is found, it will return the value in the column indicated by the contents ofB1
with 5 added to transpose to the right value. TheFALSE
parameter indicates that the lookup should do an exact match.If the value is not found, the
IFERROR
wrapped aroundVLOOKUP
will take care of inserting the0
.I shared a Google Spreadsheet example, with the formulas on
Sheet1
and the table onSheet2
.