![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Apr 2002
Posts: 21
|
if i enter a date into a cell how can i get it to display a week number?
|
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
=weeknum(A2)
|
|
|
|
|
|
#3 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,927
|
You cannot do that directly. You need to use the ToolPak Analysis AddIn, and use the WEEKNUM (I think this is the name, I don't remember it right) function.
If you need to use it in VBA, you can use the Format function like this: ?Format(Date,"ww") 21 "ww" is just like "mm" for month, but for weeks. |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
Poor man's =weeknum(a1) (not requiring tool pak) is
=ROUNDUP((A1-DATE(YEAR(A1)-1,12,31))/7,0)+(WEEKDAY(A1) < WEEKDAY(DATE(YEAR(A1),1,1))) Not fully test, but appears to work. [ This Message was edited by: IML on 2002-05-22 16:03 ] |
|
|
|
|
|
#5 | |
|
MrExcel MVP
Join Date: Mar 2002
Location: Michigan USA
Posts: 11,452
|
Quote:
Thanks for thinking for the poor man! ...how about just: =ROUNDUP((A2-DATE(YEAR(A2)-1,12,31))/7,0) As in your case, I have also not fully tested it. Regards! Edit: IML, on noting it carefully, I see mine is just the first part of your total expression -- I am wondering would this much not suffice, or is the second part of your expression also needed! [ This Message was edited by: Yogi Anand on 2002-05-22 16:54 ] [ This Message was edited by: Yogi Anand on 2002-05-22 16:57 ] |
|
|
|
|
|
|
#6 | ||
|
MrExcel MVP
Join Date: Feb 2002
Location: Denver, CO
Posts: 1,744
|
Quote:
|
||
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|