GomaPile
Active Member
- Joined
- Jul 24, 2006
- Messages
- 334
- Office Version
- 365
- Platform
- Windows
Good morning all,
Found this vba code on Google, and it works okay. Kindly asking for someone's help please if you can add more coding... if the User forgets or doesn't Select the Print Range or if the User clicks the OK button.
Apparently, its given me a pop up error. What I prefer to see is a simple message pop up box saying something like: "You have not selected a print range, please try again". Or if the User chooses to click the Cancel button it does nothing and Exit Sub.
Also, whenever the User selects a range of cells it fits/maximise to the size A3 paper in colour, in print preview, before printing.
Anyways, if you see anything else that can make the vba work better or help the User or speed up... please add more, thanks.
Regards
NASA2 (GomaPile)
Found this vba code on Google, and it works okay. Kindly asking for someone's help please if you can add more coding... if the User forgets or doesn't Select the Print Range or if the User clicks the OK button.
Apparently, its given me a pop up error. What I prefer to see is a simple message pop up box saying something like: "You have not selected a print range, please try again". Or if the User chooses to click the Cancel button it does nothing and Exit Sub.
Also, whenever the User selects a range of cells it fits/maximise to the size A3 paper in colour, in print preview, before printing.
Anyways, if you see anything else that can make the vba work better or help the User or speed up... please add more, thanks.
VBA Code:
Sub SelectPrintArea()
Dim PrintThis As Range
On Error GoTo ErrorHandler
ActiveSheet.PageSetup.PrintArea = ""
Set PrintThis = Application.InputBox _
(Prompt:="Select the Print Range", Title:="Select", Type:=8)
PrintThis.Select
Selection.Name = "NewPrint"
ActiveSheet.PageSetup.PrintArea = "NewPrint"
With ActiveSheet.PageSetup
.PrintArea = Selection.Address
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
End With
ActiveSheet.PrintPreview
Exit Sub
ErrorHandler:
'MsgBox "If error, then exit the Sub"
Exit Sub
End Sub
Regards
NASA2 (GomaPile)