VBA code so that after each page break, Excel adds a line when printing

L

Legacy 386498

Guest
Hi all,

I got a Excel file that contains all my reports that are on the same tab one after the other. Each report has his own personalize print layout (different paper size, some are on one page, others are separated on two pages, etc.)

Some report became so big after some time, that I need to print them on two pages and not one anymore. In my tab, there's only page break to separate each report, but there's other page break in the customize print layout of each report.

Is it possible that Excel adds a line when printing every time there's a page break, so when I print my report the end of the first page isn't just vertical lines, but a horizontal one to complete the table?

I search and found this: msgbox activecell.entirerow.pagebreak = xlautomatic

But it returns false and doesn't work.

Here's part of the code (which just repeats for every layout):

Sub Macro1()
'
Application.Calculation = xlManual
ActiveWindow.ScrollWorkbookTabs Sheets:=1
Sheets("Results").Select
ActiveWorkbook.CustomViews("Marge CONSO").Show
Range("D6466:D6466").Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
Range("F6466:r6466").Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("D6466:r6466").Select
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
ActiveWorkbook.CustomViews("Tri").Show
ActiveSheet.PageSetup.PrintArea = "$U$6412:$AK$6506"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWorkbook.CustomViews("CONSO").Show
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWorkbook.CustomViews("Men.Conso").Show
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.ScrollWorkbookTabs Sheets:=1
ActiveWorkbook.CustomViews("Marge H").Show
Range("D4597:D4597").Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
Range("F4597:r4597").Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Range("D4597:r4597").Select
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
ActiveWorkbook.CustomViews("Tri").Show
ActiveSheet.PageSetup.PrintArea = "$U$4543:$AK$4631"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWorkbook.CustomViews("Marge Est").Show
Range("D3440:D3440").Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
Range("F3440:r3440").Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = 1
End With
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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