View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
dan dan is offline
external usenet poster
 
Posts: 866
Default capture WEEKNUM & place in page setup

Thanks in advance. I have a spreadsheet where I setup the
page to break every Saturday (thanks Dave P.). So each
page contains Mon to Sat. My spreadsheet dates begin in
column A2. I would like to print the WEEKNUM of each page
on the page setup footer based on the first date of each
page. How would I do this?

I am not sure if I have to capture the WEEKNUM when I set
the Page Breaks, code below, and then reference the
capture on page setup or do it all on the page setup
coding.


Sub mcrAddBreaks()

Worksheets("Final").Activate
Worksheets("Final").Range("A1").Select
Dim StartRow As Long
Dim FinalRow As Long
Dim FVal As Date
Dim FirstVal As Long
Dim NVal As Date
Dim NextVal As Long
Dim i As Integer

StartRow = 2
FinalRow = Range("A65536").End(xlUp).Row

For i = StartRow To FinalRow

FVal = Cells(i, 1).Value
NVal = Cells(i + 1, 1).Value
FirstVal = Weekday(FVal)
NextVal = Weekday(NVal)
If (FirstVal = 7) And (NextVal = 2) Then
ActiveSheet.HPageBreaks.Add befo=Cells(i +
1, 1)
End If
FVal = NVal
Next i

End Sub