如果公式在 Google 表格中失败,则将单元格设为空而不是零

Make a cell empty instead of zero if its formula fails in Google Sheets

假设我有 3 个包含以下内容的单元格:

A1 = "" (Empty)
B1 = "" (Empty)
C1 = PRODUCT(A1, B1)

鉴于 A1 和 B1 为空,我假设 C1 为空。但是,C1 反而显示 0。如果 A1 的 any/both 和 B1 is/are 为空,我想要做的是让 C1 为空。有没有办法做到这一点?我在某处读到电子表格将空单元格视为 0。

只需使用If():

=IF(OR(A1="",B1=""),"",PRODUCT(A1,B1))

(如果 both 需要留空到 return "",则使用 AND()。)

你可以这样做:

=IF(LEN(A1&B1), PRODUCT(A1, B1), )