PrintOut macro from ?passed range.addrsess

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to print portions of a worksheet determined by selection from a
comboBox (Cmbindividual) on a user form (form) on clicking a button
(Cmdchoose)....code:

(rng is a public variable!)
----------------------------------------------------------------
Public Sub Cmdchoose_Click()

If Cmbindividual.ListIndex > -1 Then
indivindex = Cmbindividual.ListIndex

form.Hide

Select Case indivindex ' Evaluate Number based on name of individual
selected
Case 0
Set rng = Range("r139:ah173")
ActiveSheet.ScrollArea = rng.Address
Range("s140").Select
ActiveWindow.LargeScroll Down:=2
ActiveWindow.LargeScroll ToRight:=2
ActiveWindow.LargeScroll Down:=-2
ActiveWindow.LargeScroll ToRight:=-2

Case 1
Set rng = Range("s179:ah213")
ActiveSheet.ScrollArea = rng.Address
Range("ah212").Select
ActiveWindow.LargeScroll Down:=2
ActiveWindow.LargeScroll ToRight:=2
ActiveWindow.LargeScroll Down:=-2
ActiveWindow.LargeScroll ToRight:=-2


Case 2
Set rng = Range("r219:ah253")

ActiveSheet.ScrollArea = rng.Address
Range("s220").Select
ActiveWindow.LargeScroll Down:=2
ActiveWindow.LargeScroll ToRight:=2
ActiveWindow.LargeScroll Down:=-2
ActiveWindow.LargeScroll ToRight:=-2

Case 3
ETC.

End Select
End If
End Sub
----------------------------------------------------------------

(The scrolls are to get the thing into frame and I know there are coding
ways to select the appropriate ranges but it was late Friday PM!!!!)

What I'd like to do is put a button into each range to print out that range.

I've tried:

----------------------------------------------------------------
Private Sub CommandButton3_Click()

With ActiveSheet
.PageSetup.PrintArea = rng
.PageSetup.Orientation = xlLandscape
.rng.PrintOut
End With

End Sub
----------------------------------------------------------------
CommandButton3 is copied to each range

The rng variable applies to the ScrollArea command but rung
CommandButton3_click routine and I get an 'object required' error.

Any help would be apprecitated.

Thanks
 
Maybe:

With ActiveSheet
.PageSetup.PrintArea = rng.address(external:=true)
 

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