Week Numbers

G

gregork

If I enter a week number in a cell I want to have a formula that returns
the end date for that date (based on ISO week
numbers)

GK
 
R

Ron Rosenfeld

If I enter a week number in a cell I want to have a formula that returns
the end date for that date (based on ISO week
numbers)

GK

You can do that with a UDF.

To enter this UDF, <alt-F11> opens the VB Editor.

Ensure your project is highlighted in the project explorer window, then
Insert/Module and paste the code below into the window that opens.

Use this by entering the formula =ISOWeeknum(dt) where dt is either a date or a
cell reference containing a date.

=================================
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
================================
--ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top