Application.WorksheetFunction.Year

Seti

Well-known Member
Joined
May 19, 2002
Messages
2,916
I have a UDF that needs to compute the year of a date. The date variable (Issue) is declared as a date. When I use Application.WorksheetFunction.Year(Issue) I get a value error. Any suggestions. Thanks.

Seti
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
VBA has its own Year function, just use that instead-

Code:
Dim myYear as Integer

myYear = Year(Date)
 
Upvote 0
Thanks for the quick reply. That is indeed correct as well as month and day. The next problem is that I need the DATE function. This does not appear to have a VBA version and I am getting a value error (#VALUE) when I use the following code:

If Issue >= Application.WorksheetFunction.Date(Year(Issue), Month(Birth), Day(Birth)) Then

where Issue and Birth are both date variables.
 
Upvote 0
Take a look at the DateSerial function, does the same thing-

If Issue > = DateSerial(Year(Issue), Month(Birth), Day(Birth)) Then

etc etc
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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