Date and reference number being inserted into footer after the first page

dpaton05

Well-known Member
Joined
Aug 14, 2018
Messages
2,352
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
How do I put things into the footer on all pages after the first using vba?
 
Last edited:

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
This for the date in the Centre
VBA Code:
Sub MM1()
     With ActiveSheet.PageSetup
         .CenterFooter= Format(Now(), "mmmm d, yyyy") 
     End With
End Sub
 
Upvote 0
It is a custom reference number. I also don't anything extra in the footer on the first page.
 
Upvote 0
This is for all pages but not including the first.
 
Upvote 0
Ok, use
VBA Code:
Sub MM1()
With ActiveSheet.PageSetup
    .DifferentFirstPageHeaderFooter = True
    .FirstPage.CenterFooter.Text = ""
    .CenterFooter = Format(Now(), "mmmm d, yyyy")
End With
End Sub
 
Upvote 0
There is already a page number at the right of the footer on all pages. Therefore, on the first page, I just want the page number on the right, which is what I have.

On the second page, I also want the date on the left and in the centre I need 2 items on top of each other. The reference number, stored in the variable ref3 and the Grand total which will be in the last cell in column H.
 
Upvote 0
The above is for the second page and any page after that.
 
Upvote 0
Might have been helpful if you provide sufficient information in the first post !!
UNTESTED, as I don't have the last row in H or the ref3 variable
VBA Code:
Sub MM1()
With ActiveSheet.PageSetup
    .DifferentFirstPageHeaderFooter = True
    .FirstPage.CenterFooter.Text = ""
    .LeftFooter = Format(Now(), "mmmm d, yyyy")
    .CenterFooter = ref3 & " " & Chr(10) & .Range("H" & lr).Value
End With
End Sub
 
Upvote 0
I'm sorry, I was still formulating the question in my mind when I wrote the initial question. I will try your answer when I am next in at work on wednesday. :)
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top