Incrementing Months in Excel
If cell A1 = "06/01/2013" and A2 contained formula:
=DATE(YEAR(A1),MONTH(A1)+18,DAY(A1))
...A2 would then display "06/19/2013"
Also...
Unsure if a "date" in Excel is truly a date and not some screwed up string value?
Format it as "mm/dd/yyyy". If it doesn't conform, its still a date.
To make it manually conform, try typing it in manually. Otherwise, resort to VBA code:
Sub EstablishDates()
On Error GoTo err_EstablishDates
Dim oWS As Excel.Worksheet
Set oWS = Application.Worksheets("Sheet2")
Dim iRow As Integer
For iRow = 2 To 20
If oWS.Range("I" & iRow).Value = "" Then Exit For
oWS.Range("I" & iRow).Value = CDate(oWS.Range("H" & iRow).Value)
Next
Set oWS = Nothing
exit_EstablishDates:
Exit Sub
err_EstablishDates:
MsgBox Err.Number & " " & Err.Description
GoTo exit_EstablishDates
End Sub
Format it as "mm/dd/yyyy". If it doesn't conform, its still a date.
To make it manually conform, try typing it in manually. Otherwise, resort to VBA code:
Sub EstablishDates()
On Error GoTo err_EstablishDates
Dim oWS As Excel.Worksheet
Set oWS = Application.Worksheets("Sheet2")
Dim iRow As Integer
For iRow = 2 To 20
If oWS.Range("I" & iRow).Value = "" Then Exit For
oWS.Range("I" & iRow).Value = CDate(oWS.Range("H" & iRow).Value)
Next
Set oWS = Nothing
exit_EstablishDates:
Exit Sub
err_EstablishDates:
MsgBox Err.Number & " " & Err.Description
GoTo exit_EstablishDates
End Sub
No comments:
Post a Comment