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 :)
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 :)
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.
First, in if(condition,value_if_true,value_if_false)
you have value_if_true
and value_if_false
reversed. So the first correction is
=if(ISBLANK(A:A), "", (A:A+TIME(2, 0, 0)))
Secondly, this will only fill one row. But we can assume that you want all rows, so you can wrap it with array formula:
=arrayformula( if(ISBLANK(A:A), "", (A:A+TIME(2, 0, 0))) )
Thirdly, we may also assume row1 is the header, so you want to skip that, so you can put the function in, say, B2 instead of B1, and the range needs to be changed from A:A
to A2:A
. I don't think A2:A
range format is supported in Excel, but it's very useful in Google Spreadsheet.
You need to add arrayformula around it - and swap where your empty string is - without seeing the data essentially what you want is:
=arrayformula(if(ISBLANK(A:A),"",A:A+TIME(2, 0, 0)))
The solution I eventually was looking for was actually a slight modification of those above. I wanted the source cell to return an empty cell when the cell I was targeting was blank, otherwise I wanted it to return the value of the targeted cell (which was a boolean value):
=IFERROR(IF(ISBLANK('1578'!$B14:C14), , '1578'!$B14:C14), "")
/** Breakdown
*
* // In my use case the target had three potential values: empty (undefined), TRUE, or FALSE
* '1578'!$B14:C14
*
* // Returns true if target cell is blank
* ISBLANK('1578'!$B14:C14)
*
* // If target cell is blank, return nothing, else return value from target cell
* IF(ISBLANK('1578'!$B14:C14), , '1578'!$B14:C14)
*
* // Return first value if no error (accounts for undefined target cell value) else return blank cell
* IFERROR(IF(ISBLANK('1578'!$B14:C14), , '1578'!$B14:C14), "")
*/