Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Google sheets, how does one either return a blank cell or perform a function based on another cells lack of content?

This is what I have thus far:

=if(ISBLANK(A:A), (A:A+TIME(2, 0, 0)), "")

I'd like the script to add 2 hours to A:A or just remain blank if there is no data inside A:A

Any ideas would be greatly appreciated. Thank you :)

like image 274
Chips147 Avatar asked Feb 26 '16 07:02

Chips147


People also ask

How do I create an IF THEN formula in Google Sheets?

Using the IF Function The IF function can be used on its own in a single logical test, or you can nest multiple IF statements into a single formula for more complex tests. To start, open your Google Sheets spreadsheet and then type =IF(test, value_if_true, value_if_false) into a cell.

How do you keep a cell blank when applying formula until data?

Keep cell blank until data entered in Select first cell that you want to place the calculated result, type this formula =IF(OR(ISBLANK(A2),ISBLANK(B2)), "", A2-B2), and drag fill handle down to apply this formula to the cells you need.


1 Answers

If you want to end up with a truly 'blank' value, you can use the expression IFERROR(0/0). This is different from an empty string which is what you get when you use "". A cell with an empty string will not test true using ISBLANK(), but IFERROR(0/0) will.

For example:

=IF(ISBLANK(A1),IFERROR(0/0),"not blank")

How this works: The IFERROR function takes two arguments. If the first argument is a value, IFERROR returns that value. If the first argument returns an error, IFERROR returns its second argument - but if there is no second argument, it returns blank. We use the expression 0/0 to deliberately force an error by dividing by zero, and because there's no second argument IFERROR returns blank.

like image 143
Ian Viney Avatar answered Sep 27 '22 18:09

Ian Viney