Wader
Wader

Reputation: 9868

Select value from range based on match

I've got the following set of data and have setup a another table to the right which holds the cost of each location.

dataset

The cost column currently I've got =IF(EXACT(B2,"Home"),D2*17.2,D2*0.09), however the cost per kWh can change based on different locations. I want to be able to lookup the cost based on another table which will make things more manageable.

Lookup table

Upvotes: 0

Views: 75

Answers (1)

trincot
trincot

Reputation: 351328

You can put this formula in E2:

=VLOOKUP(B2,$G:$H,2,FALSE)*D2

It will take the value in B2, find it in the G column, take the value from the cell right to that match in the H column. This is the Cost per kWh, so it gets multiplied by D2 to arrive at the cost.

The FALSE is needed to require an exact match.

Drag/copy down the formula to the other cells in the E column.

Upvotes: 3

Related Questions