butters149
New Member
- Joined
- Mar 21, 2018
- Messages
- 23
Hello,
I created this code to apply this formula to the first row and then copy it down until the end, but then it does not work if the data/table only has one row. My code is below if anyone can help that would be great, I think it may just be something I am forgetting. thanks!
'Days Aged
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Select
ActiveCell.FormulaR1C1 = "Days Aged"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=TODAY()-RC[-4]"
Range("I2", "I" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown
Columns("I:I").Select
Selection.NumberFormat = "General"
I created this code to apply this formula to the first row and then copy it down until the end, but then it does not work if the data/table only has one row. My code is below if anyone can help that would be great, I think it may just be something I am forgetting. thanks!
'Days Aged
Columns("I:I").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("I1").Select
ActiveCell.FormulaR1C1 = "Days Aged"
Range("I2").Select
ActiveCell.FormulaR1C1 = "=TODAY()-RC[-4]"
Range("I2", "I" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown
Columns("I:I").Select
Selection.NumberFormat = "General"