Put time into cell - google-sheets

In Google spreadsheet I would like to put the time HH:mm in a cell A2 if the cell A2 is empty and if another cell A1 has a value greater than zero.
It's possible?
Now I have in A2 =If(A1>0;NOW();"") but A2 is always changing

This is a workaround but in practice may be more convenient than alternatives that may require a script. Please try adjusting your formula to:
=if(A1>0;B1;"")
where B1 is any convenient cell. Then selecting that cell with Ctrl+Shift +;. This should put the current time in B1 (or wherever) but unlike =NOW() it does not update.
Strictly speaking this does not comply with I would like to put the time HH:mm in a cell A2 if the cell A2 is empty - because A2 is the location of the formula, but I hope that is not an issue for you.

Related

How to reference an adjacent cell in google sheets relative to the selected cell

I am trying to use the =sum() function in google sheets, and so far, that's all I have typed into the targeted cell. For example, I want D3 to be the sum of C2 and D2. I know how to type that. =sum(C2,D2). But I want cells D3 thru D30 to have the same equation, relative to their adjacent cells. Something like this =sum(cell to the left, cell above). Let me know if you need more elaboration, or if you have the answer, great!
Solution
Paste this formula in the first cell next to your numbers or take a look at the Example Sheet
=IF(C2="",,IF(ISNUMBER(D1),C2+D1,0))
Explanation
We check the above cell ISNUMBER if so we calculate C2+D1 if not we put 0
IF(C2="",, to calculate onlt when the range C2:C is not Empty.
If you are looking for a single formula you can also try
=INDEX(IF(ISNUMBER(C2:C), SUMIF(ROW(C2:C),"<="&ROW(C2:C),C2:C),))

Obtain first date in column after reference date

In cell B1, I have =today() for today's date and then in the cells below (B2:B100), What I'm trying to do is to compare the date in cell B1 (today's date) and to find the next date that appear in cells B2:B100 AFTER this date and then copy this into A2.
So, in effect, in cell A2, I want a function to look up the next date in cells B2:B100 that is the nearest one AFTER B1 and then copy this into A2. I know this is a formula to add in A2 but just unsure what formula to use.
I've tried this in cell A2,
=MIN(IF(B2:B100>B1, B2:B100))
but it didn't work.
"Other things being equal", the formula is correct but should be entered in the array version (eg with Ctrl+Shift+Enter):
=ArrayFormula(MIN(IF(B2:B100>today(),B2:B100)))
Building the function from B1 into the formula is optional.

Google Spreadsheet: E2-F2 even if i move the rows

I'm having an issue with google spreadsheets. I want to... have Cell C2 always contain the difference between cell E2 and F2 even if I move the row (i don't want the formula to adapt to that change of rows, the formula should still be E2-F2); so let's say E2 contains 5 and F2 contains 3, C2 would display 2. So let's say I switch row E and row F. Right now the result displayed would still be 2, and the formula in cell C2 would've changed to F2-E2. What I want is the formula not to change, and the result displayed would be -3.
=INDIRECT(E2)-INDIRECT(F2) didn't work for me - it gave me a reference error.
The INDIRECT function expects a string parameter. So you would need to write
=INDIRECT("E2")-INDIRECT("F2")
But the better way to solve your problem would be to use absolute references
=$E$2-$F$2

A "constant" in google spreadsheet?

Say I have 2 columns: (this is extremely simplified)
Data = a number
Result = Data * 1.2
I can put B2 = A2*1.2, then drag and drop B2 down...
and it fills all the other cells, which is perfect.
But can I put this multiplier (1.2) somewhere as a "constant"? (for clarity and being easily editable)
Say I put it in E1, and set B2 = A2*E1.
Now I can't drag and drop anymore (because E1 becomes E2 E3 and so on)
In this example, is there a way to make E1 stay as you drag it down?
Short answer
Use an absolute cell reference or a named range
Explanation
Instead of E1, which is a relative cell reference, use $E$1 which is an absolute cell reference.
An alternative is to to assign a name to the cell E1, let say, "constant"
In the first case the formula will be
=A2*$E$1
In the second case
=A2*constant
References
Spreadsheet - Wikipedia
Name a range of cells - Google Docs Editors Help
I understand that you are asking for "A “constant” in Google spreadsheet?" and later on a "drag down" solution.
You can use the accepted answer, OR ...
Instead of having to drag down (increasing the number of formulas)
Use a single formula in B2
=ArrayFormula(A2:A6*E1)
You can even use it for future entries or now blank cells.
=ArrayFormula(IF(A2:A11<>"",A2:A11*E1,""))
How the formula works
The ArrayFormula will apply the calculation cell*E1 in every single row, IF the cell is not empty/blank "".
IF it is a blank cell it will return a blank cell "".
Functions used:
ArrayFormula
IF
Can you try this in your formula?
Cell B2 type
=A2*$E$1
Then there is no need to drag it down on column E, it will all follow E1.
I believe this solves the problem.
If you really want to drag it down, then why not just put Cell E2
=E1
So that even when you drag, the value will remain 1.2

Conditional formatting in Google Docs

Struggling like hell with this one but bet it's so simple!
Can do it in Libre but not in Google :-(
What I want to do is:
I have a range of cells with numbers in, ranges B8 to F20 and another set of cells in range B2 to F2
If a number in cell range B8 to F20 is same as one in range B2 to F2 I want to highlight the cell in range B8 to F20
Any help appreciated, I'm pulling my hair out :-)
Try custom formula:
Set custom formula in cell B2
=countif($B8:$F20,B2)
Apply to range B2:F2
Try selecting cells B8:F20 and click Format > Conditional formatting > Custom formula is:
=arrayformula(sum(n(value(B8)=arrayformula(value({$B$2:$F$2})))))

Resources