Page Set Up Macro: Prompt for PrintTitleRows

adam_neb

Board Regular
Joined
Jun 9, 2002
Messages
101
My Page Set Up Macro currently repeats row 1:14. I would like the Macro to prompt me to enter the last row to be included in the PrintTitleRows.

Current:

With ActiveSheet.PageSetup
.PrintTitleRows = "$1:$14"
.PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup

I use this Macro on many different spreadsheets throughout the day that come to me from many sources. However, not all require rows 1:14 to be repeated... some may be rows 1:3, 1:7, 1:5, etc. I would like to run the Macro and have a prompt appear which would allow me to enter the final row to be included in the PrintTitleRows portion of the Macro.

How would I change my Macro to prompt for this? Thank you!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Try like this

Code:
Dim i As Long
i = Application.InputBox("Enter number of rows", Type:=1)
With ActiveSheet.PageSetup
    .PrintTitleRows = "$1:$" & i
    .PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
 
Upvote 0
Perhaps something like this? It will allow you to select the rows to include when the macro runs:

Code:
Dim TitleRowRange As Range
Set TitleRowRange = InputBox("What rows would you like to include?", Type:=8)
With ActiveSheet.PageSetup
    .PrintTitleRows = TitleRowRange.Address
    .PrintTitleColumns = ""
End With
ActiveSheet.PageSetup.PrintArea = ""
With ActiveSheet.PageSetup
 
Upvote 0
Peter: that worked exactly as I needed.. thank you very much.

MrKowz: when I tried your suggestion I received an error message:
Compile error: Named argument not found
 
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,220
Members
452,895
Latest member
BILLING GUY

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