Earlyfreak
New Member
- Joined
- Jan 31, 2017
- Messages
- 16
I have a input box to select the column with the dates thenwhere I want to put the time span into words.
I am trying to use a loop to enter formula down the column but keep getting error's
I am trying to use a loop to enter formula down the column but keep getting error's
Code:
Sub DateSpan2Words()
Dim DateNumCol As Integer
Dim TimeSpanCol As Integer
Dim isnumber As Long
Dim MyCol As Long
Application.ScreenUpdating = False
On Error Resume Next
MyCol = ActiveCell.Column
DateNumCol = Application.InputBox(Prompt:="If not this column, then Enter Column Number where Date is In", Default:=MyCol, Type:=1)
TimeSpanCol = Application.InputBox(Prompt:="Enter Column Number where Time Span to be entered in", Default:=MyCol, Type:=1)
FinalRow = Cells(Rows.Count, LocNumcol).End(xlUp).row
On Error Resume Next
For i = 1 To FinalRow
).VaCells(i, TimeSpanCollue = .FormulaR1C1 = _
"=IFERROR(IF(DATEDIF(RC[-1],TODAY(),""y"")=0,"""",DATEDIF(RC[-1],TODAY(),""y"")&"" years "")&IF(DATEDIF(RC[-1],TODAY(),""ym"")=0,"""",DATEDIF(RC[-1],TODAY(),""ym"")&"" months "")&IF(DATEDIF(RC[-1],TODAY(),""md"")=0,"""",DATEDIF(RC[-1],TODAY(),""md"")&"" days""),"""")"
Next
Application.ScreenUpdating = True
End Sub
[CODE]
errors on the loop "Cells(i, TimeSpanCol).Value = .FormulaR1C1 = _"
any direction would be greatly appreciated