I have a google sheet where records arrive from a google form.
Is it possible to make it so that for each new row created (from the form) you can paste the formulas present in the row above?
I attach an image of the sheet
enter image description here
In column F2, I would like there to be an ARRAYFORMULA that allows me to copy a formula for all the new rows below (F3, F4, F5, ETC..)
In F3 (and so on) there must be a formula that calculates the difference in days from today, from the birthday date in E3.
In F4, the difference in days from today, from the birthday date in E4
In F5 …. E5
I tried this formula but it returns a value (249) and not the formula that calculates the correct days.
=arrayformula(if(len(A4:A), datedif(E4:E, today(), “YD”), iferror(ø)) )
Thanks everyone.
Matteo Social is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6
The correct thing is that:
on column F5 it put the formula: =DATA.DIFF(E5; TODAY(); “YD”);
Array formulas return multiple values automatically and do not need to be copied down.
Use datedif()
. Put this formula in cell F2
:
=arrayformula(
if(len(E2:E), datedif(E2:E, today(), "YD"), iferror(ø))
)
See datedif().
2
The goal is to calculates the difference in days from today
to the birthday date in E3
, E4
, etc., disregarding the year dates in the cells, and assume that they’re for the current year (e.g., 2024).
You may also try this in F2
:
=ARRAYFORMULA(IF(E2:E="", "", TEXT(TODAY(), "MM/DD")-TEXT(E2:E, "MM/DD")))
I’ve noticed that DATEDIF
only calculates leap years if the year provided in E2:E
is one, so for 02/06/1977
, since 2024
‘s a leap year, it returns 311
instead of 312
. This is a minor issue of a day unless you need the output to be specific.
Note: Similar to @doubleunary’s answer, you don’t need to drag the formula down since the
IF function
within theARRAYFORMULA
checks if there’s a date inColumn E
, ensuring that it only calculates the difference for valid birthday dates.
OUTPUT
Column E | TEXT & MINUS | DATEDIF |
---|---|---|
08/04/1974 | 132 | 132 |
02/06/1977 | 312 | 311 |
01/08/1984 | 341 | 341 |
01/11/1999 | 338 | 337 |
02/29/2000 | 289 | 289 |
REFERENCE
- TEXT
- MINUS function
5