if then

Copper Contributor

'=if b15 is "Roof" then c15 "1", OR if b15 is "Door c15 "2", OR if b15 is "Window" then c15 "4", 

cant get it to work ... ?

thanks in advance

1 Reply



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.



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


referring to a table like this in the range E13:F15


I'm attaching a spreadsheet with both examples working.