View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Dana DeLouis[_3_] Dana DeLouis[_3_] is offline
external usenet poster
 
Posts: 690
Default anyone have any improvements for my Weeks Function?

Would any ideas here help?

Function WeekNum(dte As Date) As Long
WeekNum = Format(dte, "ww", vbSunday, vbFirstFullWeek)
If Month(dte) = 1 And WeekNum 50 Then WeekNum = 0
End Function

Prior to the first Sunday in January, I changed the return value of 52 to 0
(zero). Adjust if you want, or just delete the second line. There is a bug
in Excel (at least XP) with this method for a specific year over 2100, but I
can't find my notes right now. It normally shouldn't be a problem though.

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"reesmacleod" wrote in message
...

I just thought I might post this function I created to get what week
number it is if a businesses week starts on a Sunday.

I am a bit of a "hack" programmer and came up with this after days of
trial and error, and would love if any professional out there could let
me know if it is "hilarious" or "ingeniuos" or any improvements anyone
might have.

This works only for the Year 2000 and above (at least to 2100).

Here is the code


<snip