Forum Discussion
Michael_Beach
Apr 13, 2023Copper Contributor
Help with vba formula to autopoulate
ActiveCell.FormulaR1C1 = "=DAYS(TODAY(),RC[-1])" Range("R2").Select Selection.AutoFill Destination:=Range("R2:R" & Range("E" & Rows.Count).End(xlUp).Row) Range(Selection, Selection.End(xlDown)).Se...
NikolinoDE
Apr 14, 2023Platinum Contributor
If I may add one more suggestion...
To fix this issue, you can use an absolute reference for the column and a relative reference for the row.
Here’s an example of how you can modify your code:
ActiveCell.FormulaR1C1 = "=DAYS(TODAY(),R[0]C[-1])"
Range("R2").Select
Selection.AutoFill Destination:=Range("R2:R" & Range("E" & Rows.Count).End(xlUp).Row)
Range(Selection, Selection.End(xlDown)).SelectThis should give you the desired result of calculating the number of days between today and each date in the column.
I hope this helps!
*All information as always without guarantee.