简体   繁体   English

Google 表格或 Excel:从公式中设置远程单元格的值

[英]Google Sheets or Excel: setting the value of a remote cell from a formula

Is there a way to create a formula in one cell that will change the value in another cell based on some criteria, without scripting?有没有一种方法可以在一个单元格中创建一个公式,该公式将根据某些标准更改另一个单元格中的值,而无需编写脚本? Example: cell a1 contains a numerical value.示例:单元格 a1 包含一个数值。 cell b1 contains a value from a drop-down list, say, "YES,NO".单元格 b1 包含下拉列表中的值,例如“YES,NO”。 If cell b1 is set to "YES" I want to remove (set to zero) the value in cell a1.如果单元格 b1 设置为“是”,我想删除(设置为零)单元格 a1 中的值。 What I'd like to do is have a formula in cell c1 that interrogates b1 and sets the value in a1 accordingly.我想做的是在单元格 c1 中有一个公式来询问 b1 并相应地设置 a1 中的值。 Is the only way achieve this writing code and using setValue?是实现此编写代码并使用 setValue 的唯一方法吗?

you cant remove it without a script.没有脚本你不能删除它。 you can visually hide it in various ways.您可以通过各种方式在视觉上隐藏它。 if the A1 is subject of further sum (as in your case per your comment) the sum formula can be always altered to reflect desired output.如果 A1 是进一步总和的主题(如您的情况根据您的评论),总和公式可以随时更改以反映所需的 output。 example:例子:

if your formula is如果你的公式是

=SUM(A1, C5, D22)

you can do你可以做

=SUM(IF(B1="YES", 0, A1), C5, D22)

Use the following on the cell you need the calculation (or zero) on:在需要计算(或零)的单元格上使用以下内容:

=IF (B1="YES",0,SUM(A:A))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM