ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   week function in vba? (https://www.excelbanter.com/excel-programming/403140-week-function-vba.html)

badazizi

week function in vba?
 
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?

John Bundy

week function in vba?
 
Make sure you have the Analysis toolpak addin and use weeknum(now()) to get
current week number
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"badazizi" wrote:

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?


Rick Rothstein \(MVP - VB\)

week function in vba?
 
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


"badazizi" wrote in message
...
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?




All times are GMT +1. The time now is 10:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com