selecting print area via inputbox

M

Mary

I am trying to do something that seems quite simple, yet I can't get it
to work. I am using the following code to get the print range from the
user. Sometimes it works, and other times nothing happens, depending
upon the range that is selected. Any ideas?

Sub SelectPrintRange()
Dim rRange As Range

On Error Resume Next
Application.DisplayAlerts = False
Set rRange = Application.InputBox(Prompt:= _
"Please use your mouse to select a select a range to be
printed.", _
Title:="SPECIFY RANGE", Type:=8)
On Error GoTo 0
Application.DisplayAlerts = True

If rRange Is Nothing Then
Exit Sub
Else
ActiveSheet.PageSetup.PrintArea = rRange.Address
ActiveWindow.SelectedSheets.PrintPreview
End If

End Sub
 
Top