Select All Sheets VBA code

markjlang

New Member
Joined
Jun 19, 2006
Messages
28
Hi there

Not sure of VBA code here. I'd like to select all sheets in VBA. Recoding macro does not work. I need to select all and then set print settings to print one page per sheet.

Many thanks
Mark
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I don't know about the printing, but selecting all of the sheets should be as simple as using Sheets.Select.
 
Upvote 0
Thanks that's done the trick.

Just wish I could loop through the sheets and set them each to print on one page. :(
 
Upvote 0
Code:
Sub PrintPageOne()
    Dim ws As Worksheet
    Dim CurSheet As Worksheet
        Set CurSheet = ActiveSheet
        For Each ws In ActiveWorkbook.Worksheets
            ws.Activate
            ActiveSheet.PrintOut _
                From:=1, To:=1, Copies:=1, Collate:=True
        Next ws
        CurSheet.Activate
End Sub
 
Upvote 0
Thanks Datsmart

Unfortunately it doesn't set the print settings to fit one page. Any ideas here?

Cheers
M
 
Upvote 0
This will set each page setting to print entire sheet on one page. Then printout each page.
Code:
Sub PrintPageOne()
    Dim ws As Worksheet
    Dim CurSheet As Worksheet
        Set CurSheet = ActiveSheet
        For Each ws In ActiveWorkbook.Worksheets
            ws.Activate
            With ActiveSheet.PageSetup
                .FitToPagesWide = 1
                .FitToPagesTall = 1
            End With
            ActiveSheet.PrintOut
        Next ws
        CurSheet.Activate
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top