View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default PrintOut macro from ?passed range.addrsess

Maybe:

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



Jabba wrote:

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

--
Jabba


--

Dave Peterson