Using a Macro to print worksheets in a workbook

dwilson38550m

Board Regular
Joined
Nov 21, 2005
Messages
66
I have a workbook with 6 or 7 worksheets in it. I would like to create a macro to print selected ranges within each of the 6 or 7 worksheets. I would then like to create a macro button and put it on the "Instructions" tab on the first page of the workbook so that the user can click the macro button and print all the required pages.

I am unsure how to select the print ranges and specify whether I would like each print over 1 or 2 pages etc. Also, could you please provide a code for me to build a macro from? I am also unsure on the macro where to type in the name of the worksheets I am referring to.

Thanks
 

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
You can start with this:

Code:
Sub printMe
    Worksheets("Sheet1").Range("C6:D9").PrintOut Copies:=1, Collate:=True
    Worksheets("Sheet1").Range("G10:J16").PrintOut Copies:=1, Collate:=True
    Worksheets("Sheet3").Range("D9:N11").PrintOut Copies:=1, Collate:=True
    Worksheets("Prices").Range("F8:K12").PrintOut Copies:=1, Collate:=True
End Sub
You can assign that to a forms button. Just specify the worksheet name and the range name (much easier with named ranges) to print ranges. You can also set a specific printer or to print to a file. Have a look in the VBA help file, also.

Hope that helps!

EDIT: Fixed code tags
 

dwilson38550m

Board Regular
Joined
Nov 21, 2005
Messages
66
Thanks,

That works - can I specify within the print ranges over how many pages I would like to print (eg for example, if I select "Sheet1" range A1:AA200, but would like this printed over 2 pages so the writing is not too small) - how can I do this?
 

Tazguy37

MrExcel MVP
Joined
May 28, 2004
Messages
4,237
You can try using the PageSetup Object to do that.

Code:
    With ActiveSheet.PageSetup
        .Zoom = False
        .FitToPagesWide = 1
        .FitToPagesTall = 2
    End With
Try that and see how it works for you!
 

Forum statistics

Threads
1,082,104
Messages
5,363,164
Members
400,720
Latest member
Pettel

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top