selecting print area via inputbox

  • Thread starter Thread starter Mary
  • Start date Start date
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top