Excel VBA Tutorial: Click on icon to run print preview (or any VBA code) by assigning macro to shape

preview_player
Показать описание
// FREE Excel E-book "Record Your First Macro"

// Recommended Excel Courses //

// Recommended Excel Templates //

If you are looking for pre-built, easy to use spreadsheets, check out Simple Sheets.

They have Excel templates covering cash flow planning, invoices, expense reports, personal budgets, and more!

——
// EPISODE NOTES

In this tutorial video we look at how to set up a Print Button on any Excel worksheet that launches Print Preview when it's clicked.

Of course... you could use the normal Print function (with keyboard shortcut CTRL + P) for this purpose...

... but the value of this solution is that you can assign any VBA Macro to the Button and quickly run it from a worksheet.

For example, you could run macros to:

- Send off emails
- Show help forms (with documentation for your spreadsheet)
- Run automated reporting processes

... all with the click of a button on your worksheet.

Here we use the .printout method to print the worksheet.

Note: VBA = Visual Basic for Applications (Excel's built-in scripting language)

——
// VIDEO TIMINGS

0:00 - Introduction
0:36 - Viewer Request Explained
1:33 - Overview of 7 steps
3:30 - Step 1 Insert Button (Form Control)
5:15 - Step 2 Set Button property to allow print object
5:31 - Step 3 Insert Printer Icon
6:18 - Step 4 Resize Printer Icon (and change color)
7:17 - Step 5 Group shapes together
8:08 - Step 6 Assign Macro
8:32 - Step 7 Write VBA Code
8:55 - Testing how the Print Button works

——
// DOWNLOAD WORKBOOK FOR THIS TUTORIAL

Please follow these instructions to learn from the workbook download:

▸ Open the workbook and make sure to enable macros

▸ Follow the 7 steps on worksheet "Info" to create your own Print Icon

▸ Press ALT + F11 to open the VBA Editor

▸ Use F8 to step through the code in a subroutine (one line at a time)

▸ I suggest you adapt this to your own needs... just copy and paste the code, then change the code to work for you

▸ If you have a viewer request, leave me a comment below and I'll try to solve your problem in a new video

——
// REFERENCES

Excel Version: 2016 (used in video)

——
// VISIT MY WEBSITE

For more tutorials on Microsoft Excel and VBA visit my website

Connect with me on Social Media
Рекомендации по теме
Комментарии
Автор


If you're totally new to Excel Macros & VBA... get my FREE e-book at this link:


Leave comments with any questions you have...

And click on the LIKE button if you found this video helpful.

Thanks for supporting my channel!

launchexcel
Автор

Thank you. This was very simple to follow and helped out alot!

srlgw
Автор

Thank you sir, your video is very useful for me.

yourfriend
Автор

Great tutorial - thank you.
I did step by step recording macro for printing 2 sheets. So:
Sheets().Select then Range().Select then Selection.PrintOut with Collate:=True and then another Sheet as the first one.
Everything works perfect. On Windows. On Mac it crash and restart whole Excel. What should I do to have it working on "all" systems?

piotrs
Автор

Hi, Thank you for the video, it really help,
I ran into an issue when tried to set the file name automatically for my invoice which have to get the invoice number from a cell with in the sheet, can you tell me where i'm wrong?

Sheet1.PrintOut, , , False, , , , ["recipt" &(.Range("H1").value)&(".pdf")], False

snackpure
Автор

How i can take print next sheet instead of active sheet. thanks in advance for your excellent help

rajj
Автор

Hi I know yours is print preview but im being instructed in my course to make it print the sheet the buttons in what will I have to change in order to do this?

megthompson
Автор

Really helpful! Thank You!
100th like!

ricardssencenko
Автор

Can you make a macro that actually prints it out, thanks

MrTosha
Автор

Hi.. I am looking for a vba file which will open a workbook and go to specific sheet and get it print and close it..after that the list of file which were found from my list should be marked in colour

Vishal-yijo
Автор

Hi, I'm trying to make macro which could highlight the matching numbers in a table when I populate number in a different table. Can you help me please?

altonfernandes
Автор

Hi, I would like to know if creating several buttons so each button will have a different printer assigned. I've created a macro for each printer but I do not know how to do it, because everytime I record a printer from the print menu list, the previous macro chooses the new printer, so each button end up printing in the last printer I recorder.... Please help

MaggYela
Автор

printing macro command not accepting in VBA

kingkhurrambutt
join shbcf.ru