cunstom function

dennisli

Well-known Member
Joined
Feb 20, 2004
Messages
1,070
I just wrote a simple custom function but it does not work. The function only show one result: No Treat Year.
Any suggestions will be appreciated.
Dennis

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 Treat Year"

End Select

End Function
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Your constant's aren't dates, there 10 divided by 1 divided by 1985, 12 divided by 1 divided by 1986 etc

If you want them to be dates try this.
Code:
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#
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top