I have a file that processes commissions in Excel. There is a macro button that I click to create a new tab for each salesperson and displays and summarizes all their customers. This works fine. The problem is, the macro doesn't change page breaks across the newly created tabs. Some of the tabs have page breaks from Column A to Column E, others are from Column A to Column D. How can I write a second macro to set the print area across all sheets from Column A to Column E except for 4 tabs named Sheet1, Sheet2, Data, Summary? It is ok if the salesperson's commission report is longer than one page, I just need to make sure all the columns fit and the report is centered on the page. This is the code that I've tried and it sets the print area from Column A to Column E but it doesn't move the page break that is between Column D and Column E.
Sub PrintArea1()
Dim i As Long
Dim ws As Worksheet
Dim WS_Count As Long
'Following line changed from ActiveWorkbook to ThisWorkbook
'because ThisWorkbook used where sheet assigned to a variable.
WS_Count = ThisWorkbook.Worksheets.Count
For i = 1 To WS_Count
Set ws = ThisWorkbook.Sheets(i)
Application.Goto ws.Cells(1, 1)
With ActiveSheet.PageSetup
.PrintArea = "A:E"
.Orientation = xlPortrait
End With
Next i
End Sub
Bookmarks