Home |
Search |
Today's Posts |
#3
![]() |
|||
|
|||
![]()
On Tue, 2 Nov 2004 09:05:01 -0800, "soren"
wrote: I am working with week numbers and need Excel to accept as week 1 the first week of the year with 4 or more days. I.e. week starting Monday 3rd January 2005 should be reflected as week 1. The program reflects this week as week 2 by default. How to change this? Here is a UDF that will compute the weeknumber: ================= Function ISOWeeknum(dt As Date) As Integer ISOWeeknum = DatePart("ww", dt, vbMonday, vbFirstFourDays) If ISOWeeknum 52 Then If DatePart("ww", dt + 7, vbMonday, vbFirstFourDays) = 2 Then ISOWeeknum = 1 End If End If End Function ======================== To enter this, <alt-F11 opens the Visual Basic Editor. Ensure your project is highlighted in the Project Explorer window, then Insert/Module and paste the above code into the window that opens. To use it, in some cell enter =ISOWeeknum(cell_ref) where cell_ref contains a date. --ron |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Line or bar graphs for tracking stocks profit and loss. | Charts and Charting in Excel | |||
I need week number in excell from a date, first week must be mini. | Excel Discussion (Misc queries) | |||
Format an excel column as a date for a 5 day week for a year. | Excel Discussion (Misc queries) | |||
Weeknum Year by Year Compare | Charts and Charting in Excel | |||
How do I annualize a standard deviation | Excel Discussion (Misc queries) |