VBA Combining Two Print Areas

slieberg

New Member
Joined
Jul 19, 2010
Messages
4
Hi,

I am trying to combine two print areas and have them print out one after another as if there was no break between them on the spreadsheet. My problem is that the first print area which is only 1 row is being given a whole page.

Here is my current code:
(top= 10; bottom = 153)

Function PrintSection(top As Integer, bottom As Integer)
Dim headerRange As Range
Dim bodyRange As Range
Dim unionRange As Range


'Set print area
Set headerRange = Range("$F$3:$H$3")
Set bodyRange = Range("$F$" & top & ":$H$" & bottom)
Set unionRange = Application.Union(headerRange, bodyRange)
With ActiveSheet
.PageSetup.PrintArea = unionRange.Address

End With

'show print dialog
Application.Dialogs(xlDialogPrint).Show

'clear print area
'ActiveSheet.PageSetup.PrintArea = ""

End Function


Anyone know why this is occurring?

Thanks!
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
That's the way it works for me if I try manually.
Must be "a feature, not a bug" :eek:

Can you just temporarily hide the rows you don't want to see ?

... or have a linked sheet for printing ?
 
Upvote 0
Hi

If you use the following you will find it prints on one page without any problem :-

Code:
With ActiveSheet.PageSetup
    .PrintArea = bodyRange.Address
    .PrintTitleRows = "$3:$3"
End With

hth

Mike
 
Upvote 0

Forum statistics

Threads
1,216,122
Messages
6,128,958
Members
449,480
Latest member
yesitisasport

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