Hello,
I didn't find any answer of my question. How I can obtain in VBA number of actual week ? I know only function in excel
Can somebody helps to me ?
Printable View
Hello,
I didn't find any answer of my question. How I can obtain in VBA number of actual week ? I know only function in excel
Can somebody helps to me ?
Check t he help files on format function. The above should return a week number.Code:format(now,"ww")
Thank You,Quote:
Originally Posted by Ecniv
but there is a small problem.
If I run this code now answer was 33-rd week, but according calendar is only 32-nd week.
I think I read a little bit about a starting week date thing in the help file on format.
Starts its count at 1 so just minus one - should be ok.Quote:
from MS Excel help on Format
Symbol Range
d 1-30
dd 1-30
ww 1-51
mmm Displays full month names (Hijri month names have no abbreviations).
y 1-355
yyyy 100-9666
If you are not sure try a couple of tests in the immediates window (ctrl+g)
Or put your own dates in and work out which week it should be in.Code:?format(cdate("01 jan 2005"),"ww")
?format(cdate("01 mar 2005"),"ww")
?format(cdate("01 jul 2005"),"ww")
?format(cdate("01 oct 2005"),"ww")
also
Quote:
from MS Excel help on Format
Format(expression[, format[, firstdayofweek[, firstweekofyear]]])
The firstweekofyear argument has these settings:
Constant Value Description
vbUseSystem 0 Use NLS API setting.
vbFirstJan1 1 Start with week in which January 1 occurs (default).
vbFirstFourDays 2 Start with the first week that has at least four days in the year.
vbFirstFullWeek 3 Start with the first full week of the year.