Button to print non-active page - How?

  • Thread starter Thread starter Bafa
  • Start date Start date
B

Bafa

Private Sub CommandButton1_Click()
Worksheets("Print Data").PageSetup.PrintArea = "$A$1:$J$40"
End Sub

I did a search and tried to combine some results of what I found wit
bits and peices of what I have been learning. Can someone show me wha
I need to do here? Active wont work, because the page named "Prin
Data" that I want printed from my workbook is not active. And m
experiment of inserting "Worksheets("Print Data")" in its place didn'
work. So what should I use instead
 
The code you have just wsets the print area. It isn't actually telling the
computer to print anything. Try the PrintOut method. You can see all of the
details in the VBA help, but for the basics it should just be:

Worksheets("Print Data").PrintOut

Dan
 
You might try;

Sub PRINT_DATA()
Sheets("CHART_DATA").Select
Range("A1:Q57").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$S$57"
dlgprintr = Application.Dialogs(xlDialogPrint).Show ' POPUP PRINT DIALOG
BOX
End Sub
 
Your code only changes the printarea. It doesn't actually print anything:

Private Sub CommandButton1_Click()
Worksheets("Print Data").PageSetup.PrintArea = "$A$1:$J$40"
Worksheets("Print Data").Printout
End Sub
 

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