I have a worksheet which is divided into 12 monthly areas named like JAN_22. I am trying to write a routine that takes the month, chosen earlier and uses this to select the relevant named range and uses this as the PrintArea. My latest attempt is this :-
Sub DoPrint(PrintMonth)
Yr = Sheets("Utilities").Range("F17").Value
SheetName = "ManagementAccounts_" & Yr
With Sheets(SheetName).PageSetup
.PrintArea = .Range(PrintMonth).Address
End With
Application.PrintCommunication = True
Sheets(SheetName).PageSetup.PrintArea
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True, _
IgnorePrintAreas:=False
End Sub
PrintMonth is one of the named ranges ie Jan_22 or Jul_22.
The attached workbook shows 3 months with named ranges for each of these.
The code above fails at .PrintArea = .Range(PrintMonth).Address.
I hope somebody can point me in the right direction,
John
Bookmarks