Application.WorksheetFunction.Year :: MrExcel Message Board


 FAQFAQ
   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   StatisticsStatistics 
 RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Online StoreOnline Store

MrExcel Message Board Forum Index -> Excel Questions

Application.WorksheetFunction.Year
Post new topic   Reply to topic
Last Thread | Next Thread  >   Printable version
  Author    Thread

Seti
Board Master


Joined: 20 May 2002
Posts: 537
Location: CT
Flag: Usa

Status: Offline

 Reply with quote  

Application.WorksheetFunction.Year

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

Post Fri Sep 19, 2003 12:55 pm 
 View user's profile Send private message

Mudface
MrExcel MVP


Joined: 19 Feb 2002
Posts: 3140
Location: Sunny, spring-like Hull
Flag: England

Status: Offline

 Reply with quote  

Re: Application.WorksheetFunction.Year

VBA has its own Year function, just use that instead-

code:
Dim myYear as Integer

myYear = Year(Date)


Post Fri Sep 19, 2003 12:59 pm 
 View user's profile Send private message

Seti
Board Master


Joined: 20 May 2002
Posts: 537
Location: CT
Flag: Usa

Status: Offline

 Reply with quote  

Re: Application.WorksheetFunction.Year

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.

Post Fri Sep 19, 2003 1:05 pm 
 View user's profile Send private message

Mudface
MrExcel MVP


Joined: 19 Feb 2002
Posts: 3140
Location: Sunny, spring-like Hull
Flag: England

Status: Offline

 Reply with quote  

Re: Application.WorksheetFunction.Year

Take a look at the DateSerial function, does the same thing-

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

etc etc

Post Fri Sep 19, 2003 1:10 pm 
 View user's profile Send private message

Seti
Board Master


Joined: 20 May 2002
Posts: 537
Location: CT
Flag: Usa

Status: Offline

 Reply with quote  

Re: Application.WorksheetFunction.Year

Thanks, that seems to do it.

Post Fri Sep 19, 2003 1:23 pm 
 View user's profile Send private message
  Display posts from previous:      

MrExcel Message Board Forum Index -> Excel Questions


Forum Jump:
Jump to:  

Post new topic   Reply to topic
Page 1 of 1



Add To Favorites

 


Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB: 2.0.4 © 2001 phpBB Group

Need help posting your first question? Read how to post

Need extra help ? Couldn't get the answer you needed ? Get a free quote from our Consulting Team

Download Colo's HTML Maker utility for displaying your Excel Worksheet on the board.

Download VB HTML Maker to post your code on the board


Check out our new index to 485 Excel Articles.


Return to MrExcel Consulting

All contents Copyright 1998-2004 by MrExcel.com
If you believe information posted here is from your copyrighted source, notify us per the Terms of Use
Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.