OaklandJim
Well-known Member
- Joined
- Nov 29, 2018
- Messages
- 833
- Office Version
- 365
- Platform
- Windows
Team Messieurs Excel
I know there is something simple that I'm missing so please have a quick look. Sub is merely trying to set the print area (and row and column headers) for printing. It hangs on my attempt to set the Print_Area range (PrintRange property) to the address of a named range. The NAME of the range (whose address) is used to set the worksheet Print_Area is specified by param psPrintArea. Here is what I have.
I know there is something simple that I'm missing so please have a quick look. Sub is merely trying to set the print area (and row and column headers) for printing. It hangs on my attempt to set the Print_Area range (PrintRange property) to the address of a named range. The NAME of the range (whose address) is used to set the worksheet Print_Area is specified by param psPrintArea. Here is what I have.
VBA Code:
Private Sub PortfolioPrintAreaSetup( _
psPrintArea, _
psRowRange, _
psColRange, _
Optional pwsSheet As Worksheet)
If IsMissing(pwsSheet) _
Then
pwsSheet = ActiveSheet
End If
Application.PrintCommunication = False
Debug.Print pwsSheet.Range(psPrintArea).Address
'Result: $A$3:$BK$112 -- the correct address
Debug.Print pwsSheet.Name
'Result: Portfolio -- the correct worksheet name
With pwsSheet.PageSetup
.PrintArea = .Range(psPrintArea).Address
.PrintTitleRows = .Range(psRowRange).Address
.PrintTitleColumns = .Range(psColRange).Address
End With
Application.PrintCommunication = True
End Sub