VBA Equivalent of the YEAR Worksheet Function

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

Is there a VBA equivalent of the YEAR worksheet function, or some other
function that would return the year of a date contained in a cell?

Thanks!
Magnivy
 
Roedd said:
Hello,

Is there a VBA equivalent of the YEAR worksheet function, or some
other function that would return the year of a date contained in a
cell?

Thanks!
Magnivy

Off the top of my head:

clng(format(dteTheDate,"YYYY"))

Rob
 
Yeah, it's called Year.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Bob,

I tried to use YEAR, but it didnt work. The DAY and MONTH functions worked
fine, but YEAR didnt. I also tried to search for YEAR Function in help, but
nothing showed up.

Magnivy
 
Is that "didn't work" as in (a) "function name not recognised", or
(b) "gave the wrong answer"?

If (a), check for missing references in the project.
If (b), can you give an example?

Andrew
 
Back
Top