View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
steve steve is offline
external usenet poster
 
Posts: 576
Default Cases/Set object to take coordinates of Print Range

Bruce,

You need to substitute the actual name of the sheet in place of MySheet.
(MySheet is just a generic). Excel is looking for the name you have
assigned to the sheet.

You may see things like MyRange, MySheet, MyBook in posted code. You must
always replace these with the names you are using. You may also see
references to $A1:$G$5 in the posted code. Again you must replace this with
the range you are using.

Remember we don't always know what your workbook looks like (or for that
matter, what other peoples workbooks look like). So we construct code with
generic references. Unfortunately many of the new comers aren't familiar
with this and get caught.

Hope this helps...

steve

"Bruce Roberson" wrote in message
...
I'd love to do somethign with a Sheets command, but it
always gives me an idiot message, in this case Run time
message 13

Private Sub btnprint1_Click()
Dim Printthisrange
Dim mysheet As Worksheet

Select Case True
Case OptCNGOBA.Value
Set Printthisrange = Range("OBACGG")
Case OptDEFSOBA.Value
Set Printthisrange = Range("OBADEFS")
Case OptAgaveOBA.Value
Set Printthisrange = Range("OBAAgave")
Case OptTWMLOBA.Value
Set Printthisrange = Range("OBATWML")

End Select
__________________________________________________ _______
Well how do I get it to recognize "Mysheet" as a reference?


Sheets("mysheet").Printthisrange.Select

With Sheets("MySheet").Printthisrange
.PrintTitleRows = ""
.PaperSize = xlPaperLegal
.FitToPagesWide = 1
.FitToPagesTall = 1
.Orientation = xlLandscape
End With
Unload Me
Printthisrange.Select
Printthisrange.PrintPreview
Printthisrange = "Nothing"
Range("a1").Select


End Sub