Hello all,
I have an excel spreadsheet with 20 worksheets and 2 to 4 pages in each of the worksheets; each page needs to have a specific footer.
I have been trying adding VB code into a macro to do the trick, but so far I have not been successful.
The code I have is looking for the value in cell "A1" and then adding +1 in each of the pages in the worksheet by using a loop (Next)
This is the code I have so far:
Public Sub Footer()
Cancel = True
Dim ws As Worksheet
Dim Footer As Variant
Dim Footer2 As Variant
Dim i As Long
Application.ScreenUpdating = False
For Each ws In Worksheets
If ws.Visible Then ws.Activate
With Sheets("sheet1").PageSetup
Footer = Sheets("sheet1").Range("A1")
For i = 1 To .Pages.Count
Footer2 = Footer + i
.RightFooter = " "
.RightFooter = "&""Calibri""&9&O" & Footer2
Next i
End With
Next
End Sub
I will really appreciate and help, I have been working on this project for a few days and I am out of ideas.
Thank you,
Ferny
I have an excel spreadsheet with 20 worksheets and 2 to 4 pages in each of the worksheets; each page needs to have a specific footer.
I have been trying adding VB code into a macro to do the trick, but so far I have not been successful.
The code I have is looking for the value in cell "A1" and then adding +1 in each of the pages in the worksheet by using a loop (Next)
This is the code I have so far:
Public Sub Footer()
Cancel = True
Dim ws As Worksheet
Dim Footer As Variant
Dim Footer2 As Variant
Dim i As Long
Application.ScreenUpdating = False
For Each ws In Worksheets
If ws.Visible Then ws.Activate
With Sheets("sheet1").PageSetup
Footer = Sheets("sheet1").Range("A1")
For i = 1 To .Pages.Count
Footer2 = Footer + i
.RightFooter = " "
.RightFooter = "&""Calibri""&9&O" & Footer2
Next i
End With
Next
End Sub
I will really appreciate and help, I have been working on this project for a few days and I am out of ideas.
Thank you,
Ferny