Home > OS >  Google Sheets or Excel: setting the value of a remote cell from a formula
Google Sheets or Excel: setting the value of a remote cell from a formula

Time:12-09

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. cell b1 contains a value from a drop-down list, say, "YES,NO". If cell b1 is set to "YES" I want to remove (set to zero) the value in cell a1. What I'd like to do is have a formula in cell c1 that interrogates b1 and sets the value in a1 accordingly. Is the only way achieve this writing code and using setValue?

CodePudding user response:

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. example:

if your formula is

=SUM(A1, C5, D22)

you can do

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

CodePudding user response:

Use the following on the cell you need the calculation (or zero) on:

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