PDA

View Full Version : Solved: Pop Up Window to Select Range



r_know
07-04-2012, 10:40 AM
Dear All,

I required when I Macro run then open the POP Window to select range.

Here, I want Pop Up window says, Select Range then Range


ActiveSheet.Range("B2:I18").Select


Kindly Advise.

Regards,

RL

Bob Phillips
07-04-2012, 10:48 AM
Set rng = Application.InputBox("Select a Range",Type:=8)

r_know
07-04-2012, 11:34 AM
Thanks;; POP window Open perfect,

But when I input range A1:I20 which not selecting.
Also, if I need to cancel, then which code should follow to close POP Window.

Regards,
RL

Bob Phillips
07-04-2012, 11:41 AM
It only gets a range variable, you then have to select it.

Test the range variable for Nothing to exit.

r_know
07-04-2012, 12:38 PM
Dear Xld,

My Aim to Print Selected Area. Therefore, I want POP up window to select range; but after selection PRINT does not coming, can you check code pls?

Regards, RL


Sub Printsheet1()

'Select Range of PRINT

Set Rng = Application.InputBox("Select a Range", Type:=8)
With ActiveSheet.PageSetup
.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With
Selection.PrintOut Copies:=1, Collate:=True
ActiveSheet.Range("B2").Select
End Sub

Bob Phillips
07-04-2012, 03:42 PM
Sub Printsheet1()
Dim rng As Range
'Select Range of PRINT

On Error Resume Next
Set rng = Application.InputBox("Select a Range", Type:=8)
On Error GoTo 0
If Not rng Is Nothing Then

With ActiveSheet.PageSetup

.LeftHeader = ""
.CenterHeader = ""
.RightHeader = ""
.LeftFooter = ""
.CenterFooter = ""
.RightFooter = ""
.LeftMargin = Application.InchesToPoints(0.5)
.RightMargin = Application.InchesToPoints(0.5)
.TopMargin = Application.InchesToPoints(0.5)
.BottomMargin = Application.InchesToPoints(0.5)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.5)
.PrintHeadings = False
.PrintGridlines = False
.PrintComments = xlPrintNoComments
.PrintQuality = 600
.CenterHorizontally = False
.CenterVertically = False
.Orientation = xlLandscape
.Draft = False
.PaperSize = xlPaperLetter
.FirstPageNumber = xlAutomatic
.Order = xlDownThenOver
.BlackAndWhite = False
.Zoom = False
.FitToPagesWide = 1
.FitToPagesTall = 1
.PrintErrors = xlPrintErrorsDisplayed
End With

rng.PrintOut Copies:=1, Collate:=True
End If
End Sub

r_know
07-04-2012, 08:46 PM
Great XLD

Many Thanks....

It worked....

Regards,
RL