week function in vba?

B

badazizi

I don't know if one exists or not, but is there a function in VBA that would
return a number representing the week of the year (0-51, or 1-52) when passed
a date? similar to how year() or day() pulls out the year or day portion of
a given date?
 
J

John Bundy

Make sure you have the Analysis toolpak addin and use weeknum(now()) to get
current week number
 
R

Rick Rothstein \(MVP - VB\)

You would use the DatePart function with "ww" as the 1st argument (with the
date as the 2nd argument). There are optional 3rd and 4th arguments which
can modify how DatePart functions, so you should look this function up in
the help files (type DatePart and then, with the text caret in or next to
the word, hit the F1 key).

Rick
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top