Footer formula

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
574
Office Version
  1. 365
Platform
  1. Windows
I have a sheet that dynamically fills in as a number is entered into a cell. If 240 is entered I get four pages. Page 1 and 2 go together and pages 3 and 4 go together. In this case the footer reads "Page 1 of 4"... etc. If 120 or less is entered I have two pages of complete data, pages 1 and 3 are complete and 2 and 4 remain blank. My footer still reads "Page 1 of 4"..., but I only have two pages of information. Is it possible to place a formula in the footer to account for the change in value? In other words to force Y (Page X of Y) to be either 2 or 4 as appropriate.

For example: If(Z1<=120, 2, 4)

This would use 2 as the total number of pages if the value in Z1 was 120 or less and 4 as the total number of pages otherwise.

I just don't know how to incorporate this formula into the footer text of

'Page &[Page]& of &[Pages]'

Any help on how to do this would be great.

Thanks,

Robert
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I've tried the following and get a RunTime Error 13 type mismatch with the error on the blue text. Don't know what to do.

Rich (BB code):
Sub Print_Initiation_Page()

If Range("AE1").Value > 120 Then
    With Worksheets("Inspection Sheet Initiation").PageSetup
        .CenterFooter = "Page " & [Page] & " of 4"
    End With
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    
    Else
    With Worksheets("Inspection Sheet Initiation").PageSetup
        .CenterFooter = "Page " & [Page] & " of 2"
    End With
        Sheets("Inspection Sheet Initiation").PrintOut From:=1, To:=1
        Sheets("Inspection Sheet Initiation").PrintOut From:=3, To:=3
    ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
    
End If

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,609
Messages
6,179,881
Members
452,948
Latest member
Dupuhini

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