Prints Sheets and SaveAS Macro

robgoldstein

Board Regular
Joined
Oct 26, 2013
Messages
165
Office Version
  1. 2019
Platform
  1. Windows
I want to create a macro that Prints 3 sheets from my workbook and then launches the saveAs window

The 3 sheets I am looking to print are "Team 1" "Team 2" & "Team 3"

Is this possible to do in one macro since there are windows that will pop up for both printing and save as?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
The 3 sheets are the ones that go to a new book so you can save it, if it's correct, try this:

Code:
Sub print_save()
  Dim shs
  shs = Array("Team1", "Team2", "Team3")
  Sheets(shs).PrintOut
  Sheets(shs).Copy
  With Application.FileDialog(msoFileDialogSaveAs)
      .Title = "Save as"
      .AllowMultiSelect = False
      .FilterIndex = 2
      If .Show Then
          ActiveWorkbook.SaveAs Filename:=.SelectedItems(1), FileFormat:=xlOpenXMLWorkbookMacroEnabled
          ActiveWorkbook.Close False
      End If
  End With
End Sub
 
Upvote 0
Thanks so much Dante,
unfortunately I get a Script out of range error on the
Code:
 Sheets(shs).PrintOut
 
Upvote 0
In the code, put space after Team, eg. Team 1, Team 2, Team 3.
 
Upvote 0
In this line the names of your sheets should go identically, check if there are spaces on the left or on the right

Code:
[COLOR=#333333]Array("Team 1", "      Team 2", "Team 3    ")[/COLOR]
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,973
Members
452,540
Latest member
haasro02

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