print 20 cells with a command button

R

ronbinette

I received a few suggestions but the gave me errors.
I would like to create a button on a sheet to print C31 to C50 when I
press on it.
I've only one sheet called MTI.
I'd really like to make this work. Thank you if you can help me.
Ron Binette
 
G

Gord Dibben

Sub Print_Range()
Sheets("MTI").PageSetup.PrintArea = "$C$31:$C$50"
ActiveWindow.SelectedSheets.PrintPreview
'Change PrintPreview to PrintOut for printing
End Sub

I added the sheet name just in case you ever insert another sheet.


Gord Dibben MS Excel MVP
 
R

ronbinette

Sub Print_Range()
       Sheets("MTI").PageSetup.PrintArea = "$C$31:$C$50"
             ActiveWindow.SelectedSheets.PrintPreview
      'Change PrintPreview to PrintOut for printing
End Sub

I added the sheet name just in case you ever insert another sheet.

Gord Dibben  MS Excel MVP





- Show quoted text -

I've tried that and I get this compile error.
This is how I entered it

Private Sub CommandButton1_Click()
Sub Print_Range()
Sheets("MTI").PageSetup.PrintArea = "$C$31:$C$50"
ActiveWindow.SelectedSheets.PrintOut
'Change PrintPreview to PrintOut for printing
End Sub
End Sub
What am I doing wrong?
Thank you
 
D

DS-NTE

Delete:
Sub Print_Range()
and one End Sub
try again....


<[email protected]> skrev i melding
Sub Print_Range()
Sheets("MTI").PageSetup.PrintArea = "$C$31:$C$50"
ActiveWindow.SelectedSheets.PrintPreview
'Change PrintPreview to PrintOut for printing
End Sub

I added the sheet name just in case you ever insert another sheet.

Gord Dibben MS Excel MVP





- Show quoted text -

I've tried that and I get this compile error.
This is how I entered it

Private Sub CommandButton1_Click()
Sub Print_Range()
Sheets("MTI").PageSetup.PrintArea = "$C$31:$C$50"
ActiveWindow.SelectedSheets.PrintOut
'Change PrintPreview to PrintOut for printing
End Sub
End Sub
What am I doing wrong?
Thank you
 
Top