Mar 03 2023 04:41 PM
There are at least two ways to do it.
Here, entered into cell C15, would be the easiest, but also the less robust, more problematic in the long run.
=IFS(B15="Roof",1,B15="Door",2,B15="Window",4)
Why is that more problematic in the long run, you ask: because you are "hard-coding the values" into the formula. But values like that often change over time, and hard-coded values are not "visible" ...
So a more reliable and more readily maintained approach is to put those kinds of variables into a table and use one of the many LOOKUP functions in a formula such as this
=VLOOKUP(B15,E13:F15,2,0)
referring to a table like this in the range E13:F15
I'm attaching a spreadsheet with both examples working.