HDTutorial
EN

Playback starts YouTube’s embedded player (privacy-enhanced mode).

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

93,448 views October 26, 2018 11:02

Watch on YouTube
ChannelLaunch Excel

Chapters

Description from the creator

// FREE Excel E-book "Record Your First Macro"
→ launchexcel.com/record-your-first-macro-ebook

// Recommended Excel Courses //

1. Launch Excel Macros & VBA School: go.launchexcel.com/macros-vba-school-youtube
2. Excel Campus Elevate Program: go.launchexcel.com/excel-campus-elevate-youtube
3. My Online Training Hub Dashboards: go.launchexcel.com/moth-dashboard-course-youtube
4. Coursera Excel Specialisation: go.launchexcel.com/coursera-excel-specializatio…
5. Coursera Everyday Excel: go.launchexcel.com/coursera-everyday-excel-yout…
6. Coursera Excel Data Visualisation: go.launchexcel.com/coursera-data-vizualization-…

// Recommended Excel Templates //

If you are looking for pre-built, easy to use spreadsheets, check out Simple Sheets.
go.launchexcel.com/simple-sheets-templates-yout…

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

DOWNLOAD WORKBOOK → launchexcel.com/media/samples/VBA/20180416-VBA_…

——
// 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:

▸ Download the sample Excel workbook: launchexcel.com/media/samples/VBA/20180416-VBA_…

▸ 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
→ launchexcel.com

Connect with me on Social Media
→ twitter.com/VictorChan_

About this tutorial

Launch Excel published this 11:02 video tutorial on October 26, 2018. It has been watched 93,448 times on YouTube.

Category
Education
Duration
11:02
Published
October 26, 2018
Views
93,448
Likes
841

Tags

Share

Further reading

  • How to run macro in Excel and create a macro button ablebits.com

    One of the fastest ways to execute VBA in Excel is to run a macro from the Developer tab. If you have never dealt with VBA code before, you may need to activate the Developer tab first. And then, do the following: On th…

  • Add a Button and Assign a Macro in Excel - Automate Excel automateexcel.com

    Here you can assign an existing Macro to the button, record a new macro, create a new macro from scratch using VBA, or click “Cancel” and return to your button later. Assign Existing Macro to a Button. To assign an exis…

  • Print Worksheets VBA - Excel Macros excelhowto.com

    In Excel, when you click the Print button, Excel will not print hidden sheets, except use VBA.Here is a large examples of print Worksheets use Excel VBA, Before you read this tutorial, you may need to know the differenc…

This tutorial in other languages