|
-
Aug 11th, 2005, 03:03 AM
#1
Thread Starter
Junior Member
Number of week
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 ?
-
Aug 11th, 2005, 03:20 AM
#2
Re: Number of week
Check t he help files on format function. The above should return a week number.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 11th, 2005, 03:27 AM
#3
Thread Starter
Junior Member
Re: Number of week
 Originally Posted by Ecniv
Check t he help files on format function. The above should return a week number.
Thank You,
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.
-
Aug 11th, 2005, 07:43 AM
#4
Re: Number of week
I think I read a little bit about a starting week date thing in the help file on format.
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
Starts its count at 1 so just minus one - should be ok.
If you are not sure try a couple of tests in the immediates window (ctrl+g)
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")
Or put your own dates in and work out which week it should be in.
also
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.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|