View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Friday of a given week

Sub AddFridays()
RowNum = 1
MyYear = 2009
NewYears = DateSerial(MyYear, 1, 1)
LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
DayofWeek = Weekday(NewYears, vbFriday)
FirstFriday = NewYears + ((8 - DayofWeek) Mod 7)

'add new row
Rows(RowNum).Insert

For ColCount = 1 To LastCol
WeekNum = Cells(RowNum + 1, ColCount)
FridayofWeek = FirstFriday + (7 * (WeekNum - 1))
Cells(RowNum, ColCount) = Format(FridayofWeek, "yyyy-mmm-dd")
Next ColCount


End Sub


"QB" wrote:

I have a row with week numbers and would like to insert a row above it which
list the Friday of that week number. How can I do this?

Week 19 would give 2009-May-08 (yyyy-mmm-dd)

Thank you

QB