Possible Duplicate:

Sum Values in One Range Based on Criteria in Another

I have a spreadsheet with a list of weights and another list based on a drop-down selection with the choices "Yes" and "No" and I need to make a weighted sum from it.

Right now I have a very nasty looking function:

```
=D5*IF(E5="Yes",1,0)+D6*IF(E6="Yes",1,0)+D7*IF(E7="Yes",1,0)+D8*IF(E8="Yes",1,0)+D9*IF(E9="Yes",1,0)+D10*IF(E10="Yes",1,0)
```

I'd like to find a way to simplify this. A sample set of data looks like this:

```
+---+-----+
| 1 | Yes |
+---+-----+
| 4 | No |
+---+-----+
| 1 | Yes |
+---+-----+
| 2 | Yes |
+---+-----+
| 2 | No |
+---+-----+
```

This would produce a result of 1+1+2=4

Is there any way to get results like this in a simpler way than the way I'm currently using?