Macro to Print Specific # of Pages based on a cell's value

liquidmettle

New Member
Joined
May 23, 2013
Messages
48
Hi Everyone,

I am looking to develop a macro that will be tied to a button.

When a user presses the button, I want a specific number of pages to print based on a single cell's value.

Here are the particulars:

Sheet name: Reporting

Merged Cell that determines # of pages printed: EK25:EO26 (I don't know if the range the merged cell covers is important, but the top most left cell is EK25).

Possible Values for EK25: "Page 1", "Page 2",......, "Page 15". (Values in worksheet are without quotations).

I have set up, using page break view, a total of 15 pages (all vertically, no pages next to one another in the page break preview).

The total print range is from CO12 to DY481 (With the way the document is formatted, this is exactly 15 pages, normal 8 x 11.5 portrait orientation).

So what I want is a button that will print from page 1 to whatever value is listed in EK25.

If there is no data, EK25 will read "No Matching Criteria".

Is this function possible?

Thanks all in advance, you guys rock!
 
How about just hiding the rows you don't want printed?
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
The following code works a bit but not what I want
Code:
Sub PrintToPageX()
    Dim rng As Range
   Set rng = Range("Z1:Z5")
          
    ActiveWindow.SelectedSheets.PrintOut From:=rng, To:=rng
    
End Sub

It prints all pages as separate files. I want it as one file.
 
Upvote 0
How about just hiding the rows you don't want printed?

I have tables and charts on pages 3, 5, and 7. If I hide the rows not wanting to print, the chart does not pick the values and shows empty with #REF!
 
Upvote 0
Select the chart, click Select Data, click Hidden and Empty Cells, tick Show data in hidden rows and columns
 
Upvote 0

Forum statistics

Threads
1,216,445
Messages
6,130,685
Members
449,585
Latest member
Nattarinee

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