Good morning,
I have a custom function TreatYear. It works if I use it in Excel worksheets.
But when I put in Sub code, the builtin function only give me “No Treaty Year” results. The Sub code works well with other With End With.
Any ideas will be appreciated.
Dennis
Here is my Sub code:
With Range("F9:F" & DataLastRow2)
.Formula = "=TreatYear(Data!E9)"
.Value = .Value
End With
Here is my simple TreatYear function:
Public Function TreatYear(LossDate)
Const TY1985B = #10/1/1985#
Const TY1986B = #12/1/1986#
Const TY1987B = #12/1/1987#
Const TY1985E = #11/30/1986#
Const TY1986E = #11/30/1987#
Const TY1987E = #11/30/1988#
Select Case LossDate
Case TY1985B To TY1985E: TreatYear = 1985
Case TY1986B To TY1986E: TreatYear = 1986
Case TY1987B To TY1987E: TreatYear = 1987
Case Else: TreatYear = "No Treaty Year"
End Select
End Function
I have a custom function TreatYear. It works if I use it in Excel worksheets.
But when I put in Sub code, the builtin function only give me “No Treaty Year” results. The Sub code works well with other With End With.
Any ideas will be appreciated.
Dennis
Here is my Sub code:
With Range("F9:F" & DataLastRow2)
.Formula = "=TreatYear(Data!E9)"
.Value = .Value
End With
Here is my simple TreatYear function:
Public Function TreatYear(LossDate)
Const TY1985B = #10/1/1985#
Const TY1986B = #12/1/1986#
Const TY1987B = #12/1/1987#
Const TY1985E = #11/30/1986#
Const TY1986E = #11/30/1987#
Const TY1987E = #11/30/1988#
Select Case LossDate
Case TY1985B To TY1985E: TreatYear = 1985
Case TY1986B To TY1986E: TreatYear = 1986
Case TY1987B To TY1987E: TreatYear = 1987
Case Else: TreatYear = "No Treaty Year"
End Select
End Function