|
Print Preview Display for Specific Worksheets in Excel
This free Excel macro allows you to display the print preview mode or window in Excel for a specified Excel worksheet. This is a great macro to use with workbooks whose worksheets will not change or for templates.
To display the print preview mode for the desired worksheet in Excel, replace "WorksheetNameGoesHere" with the actual name of the worksheet, which is located on the tab. You can also set this equal to a variable and then use a user input form or some other method to dynamically pull in the name of a worksheet to view in the print preview mode.
Where to install the macro: Module
Macro to Display Print Preview for Specific Worksheets in Excel
Sub Print_Preview_SpecificWorksheet()
'Show the print preview window for a specific Excel worksheet
Worksheets("WorksheetNameGoesHere").PrintPreview
End Sub
How to Install the Macro
- Select and copy the text from within the grey box above.
- Open the Microsoft Excel file in which you would like the Macro to function.
- Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.
Or For other ways to get there, Click Here.
For Excel Versions Prior to Excel 2007 Go to Tools > Macros > Visual Basic Editor
For Excel 2007 Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic
- On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.
- If the Macro goes in a Module, Click Here, otherwise continue to Step 8.
- Go to the menu at the top of the window and click Insert > Module
- Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
- Go to Step 8.
- If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Go to Step 8.
- If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.
- Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
- Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
- A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
- Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
- Go to Step 8.
- Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.
- You are now ready to run the macro.
Similar Helpful Excel Resources
Hi There,
Am wanting to write some code that displays a sheet in print preview, waits for 10 seconds, then moves onto another sheet but seems that whenever print preview is on, the macro stops running until the preview is manually closed.
Any thoughts?
Cheers - Paul
My workbook has several rows at the top which I want to use as a header for the first few pages, but not the last. So I've used some VBA code in the beforeprint event to cancel the print job, print the first few pages of the workbook, hide the unwanted rows and then print the last page.
It worked fine in Excel 2003 but in Excel 2007 the print preview command bar is not displayed so the user has no way of closing the print preview except closing the application from the taskbar.
Is there a way of displaying the print preview commandbar in Excel 2007?
(See Attached Screenshot)
When one is in the Main Menu (screen is not maximized) of the timesheets for a fiscal year, there are magnifying glasses that allow one to view the "Print Preview" screen for each pay cycle. Right now, when one clicks on a magnifying glass, it shows the respective "Print Preview" screen shrunk to fit the non-maximized screen. Is there a way to make it automatically show the full screen version of the "Print Preview" upon clicking on the magnifying glass?
I have changed what I am doing with this, rendering the question moot. Thanks anyway :-)
Is there anyway of scrolling through all worksheets in a workbook in print
preview. Rather than having to close the print preview, select the next
worksheet and then go to print preview again.
adjusting columns in multiple worksheets of workbook in print preview
--------------------------------------------------------------------------------
how can I adjust columns in worksheets of a workbook, when they are in print preview and not the same number of columns or widths in each sheet. (the widths would differ because of the size of width of numbers and there could be some extra facts making it necessary to have some more columns in some sheets) Can I do this by using a few simple steps covering all worksheets at once, instead of going into 45 worksheets and double clicking on columns at the top. Would someone be able to help me with this. thanks.
I am having a problem with the new version of Excel 2010. These documents will show up correctly, then when viewed in the print preview window be wrong. I have re-opened these files in older versions ( Excel 2007 and Excel 2003) and they display correctly and print correctly. In the new version of excel the text in the "Combo Boxes" are changing font size upon printing. This even holds true for the print preview window. I have also tried this on another computer which has Excel 2010 and I have the same problem. Here are some links to view the problem I've been having. Any help would greatly be appreciated!
This is a picture of the printing error.
http://i616.photobucket.com/albums/t...INT3-17-11.jpg
This is a picture of what it should look like when printed correctly.
http://i616.photobucket.com/albums/t...INT3-17-11.jpg
Many of the excel documents I've created in the past week have print preview issues. I set up everything the way I want it to print in page break preview - all of the breaks are in the right place and the page layout view looks correct . However, in print preview and when simply printing, the page breaks are not correct at all . In one document, a picture I have at the top of the sheet changes locations on my page and begins overlapping data I have below it.
I have not been able to find any solution for this problem so far. Please help if you can! I have to print a lot of excel documents on a daily basis.
Thanks!
I have Excel 2003 here at work and can't find out how to change the print
preview display to show color instead of only black and white. Please advise
because it's useless only seeing b&w when I need to see how colors look
together, etc.
Thank you in advance
|
|