这个
真实的
问题是何时
I15
为空。使用“Evaluate Formula”工具运行一遍,您应该会看到它,但如果您将代码分解并使用缩进/新行等格式进行格式化,则:
=IF(I15="Truck",
CLEAN(
SUBSTITUTE(
SUBSTITUTE(TRIM(C15),"and ","And"), 'Should this be "and" rather than "and " to match the "Bus" and "Car"?
CHAR(32),
""
)
),
IF(I15="Bus",
CLEAN(
SUBSTITUTE(
SUBSTITUTE(TRIM(C15),"and","And"),
CHAR(32),
""
)& "B1"
),
IF(I15="Car",
CLEAN(
SUBSTITUTE(
SUBSTITUTE(TRIM(C15),"and","And"),
CHAR(32),
""
)
), 'Should this bracket be after the "C1" instead of here?
""
)& "C1"
)
)
现在,跟踪if
I15
为空:
I15
不是“卡车”,并且
I15
不是“公共汽车”,所以我们得到:
=IF(FALSE,
N/A,
IF(FALSE,
N/A,
IF(I15="Car",
CLEAN(
SUBSTITUTE(
SUBSTITUTE(TRIM(C15),"and","And"),
CHAR(32),
""
)
), 'Should this bracket be after the "C1" instead of here?
""
)& "C1"
)
)
将其简化,您将获得:
IF(I15="Car",
CLEAN(
SUBSTITUTE(
SUBSTITUTE(TRIM(C15),"and","And"),
CHAR(32),
""
)
),
""
)& "C1"
但是
I15
是空白的,不是“车”,所以它变成
IF(FALSE, N/A, "") & "C1"
-意思是,如果
I15
不是“公共汽车”或“卡车”。
此外,您可能可以将代码简化为
=CLEAN(SUBSTITUTE(SUBSTITUTE(TRIM(C15),"and","And"),CHAR(32),"")) & IF(I15="Bus", "B1", IF(I15="Car", "C1", ""))
如果你能在某处摆好桌子,你可以改变
IF
对a的声明
VLOOKUP
,或者如果您有一个下拉列表,则可以使用
CHOOSE(MATCH(..))