硬编码比较

时间:2015-11-03 20:41:16

标签: google-sheets

我正在制作一个计算器风格的电子表格,用于快速轻松地计算通常乏味的方程式,只需点击几下即可。但是,我遇到了麻烦。

在B3中,我列出了用户的各种可能选择。根据他们选择的内容,大量其他单元格将更改值以显示正确和所需的信息。

我首次尝试根据所使用的B3的内容来设置格式化格式:

 =IF(ISNUMBER(SEARCH("Plate",B3)),"Quake",ISNUMBER(SEARCH("Cloth",B3)),"Ocean",ISNUMBER(SEARCH("Leather",B3)),"Typhoon",ISNUMBER(SEARCH("Neck",B3)),"Earth",ISNUMBER(SEARCH("ring",B3)),"Earth",ISNUMBER(SEARCH("Dagger",B3)),"Mountain",ISNUMBER(SEARCH("Sword",B3)),"Summer",ISNUMBER(SEARCH("Katana",B3)),"Sky",ISNUMBER(SEARCH("Club",B3)),"Autumn",ISNUMBER(SEARCH("Shortspear",B3)),"Winter",ISNUMBER(SEARCH("Axe",B3)),"Typhoon",ISNUMBER(SEARCH("Greatsword",B3)),"Desert",ISNUMBER(SEARCH("Nodachi",B3)),"Lightning",ISNUMBER(SEARCH("Greataxe",B3)),"Desert",ISNUMBER(SEARCH("Greatclub",B3)),"Sunset",ISNUMBER(SEARCH("Longspear",B3)),"Squall",ISNUMBER(SEARCH("Shield",B3)),"Quake",ISNUMBER(SEARCH("Bow",B3)),"Volcano",ISNUMBER(SEARCH("Scepter",B3)),"Meadow",ISNUMBER(SEARCH("Staff",B3)),"Ocean","")

我遇到的问题是IF最多需要三个参数。

有没有办法绕过这个,可能是通过使用许多OR语句分解比较?

1 个答案:

答案 0 :(得分:0)

您可以嵌套IF语句。语法确实是三个参数,比如=IF(test,a,z)。因此,如果第一次测试失败,您可以为该案例添加第二个测试:=IF(test1,a,IF(test2,b,z))和第三个=IF(test1,a,IF(test2,b,IF(test3,c,z))),依此类推。