Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Running a macro

From: Excel 2013 Essential Training

Video: Running a macro

When you want to use a Macro, you will hear the term Playback the Macro, Execute it, Run it, Activate it. The whole idea is you've created a macro and you want to make it work; make it do what it's supposed to do. And when you're getting started with Macros, the preferred method tends to be a keystroke shortcut, but there are other ways as well. Let's create a new macro here and also consider the idea that sometimes the macro you want to create and then Run is stored in such a way that it will always be available regardless of which workbook is open.

Running a macro

When you want to use a Macro, you will hear the term Playback the Macro, Execute it, Run it, Activate it. The whole idea is you've created a macro and you want to make it work; make it do what it's supposed to do. And when you're getting started with Macros, the preferred method tends to be a keystroke shortcut, but there are other ways as well. Let's create a new macro here and also consider the idea that sometimes the macro you want to create and then Run is stored in such a way that it will always be available regardless of which workbook is open.

In this worksheet called PricingSheet, there are a lot of cells with formulas, a lot of cells with just pure numbers. And let's imagine that we want to highlight just the cells with numbers. So let's create a macro here, VIEW tab, drop-arrow or for Macros, choose Record Macro. And we're going to call it something along the lines of HighlightValueCells. Macro names cannot have spaces, this time it will just use upper and lower case value cells.

Keystroke shortcut, V is the key letter perhaps, we're thinking of value, how about Ctrl+Shift, I'm holding down the Shift key as I type the letter V. If we want our macro to be available in any workbook, in other words if we create this macro and then close the current workbook, we still want to be able to use this macro. So we don't want to store it in this workbook. The other term that might surprise you, Personal Macro Workbook. If it were called Global Macro Workbook, perhaps it might be a little more pertinent in terms of what it means.

If you store a macro in this location, it means that in the future, regardless of which workbook is open, you will be able to use Run, Activate, Execute, whatever the term you're using this particular macro. Personal Macro Workbook might not even exist right now. Ultimately simply by clicking OK and recording this macro, you are in effect creating this if you haven't already created it. And the name of that will be Personal.XLSB, its complete name of file extension.

That's perhaps a little bit of trivia but at the same time; I want to emphasize the idea that the Personal Macro Workbook is a separate workbook. And once you create it and we can simply do as we're about to do it here by a recording a macro and placing it there, this workbook is always available in the future regardless of which file is open. It is stored on the current computer you're using. And so what happens sometimes is you will want to copy certain macros elsewhere, but we simply want to record this macro so that it's available to all workbooks.

And all we want to do in this macro is to highlight the cells that have values, so we'll click OK. And the process begins for this command sequence; go to the HOME tab in the ribbon and the extreme right button, Find & Select. This is a feature that many people might use, not everybody, so we always want to be reminded that macros although we might think of them as being ideal for us, aren't necessarily for everybody. Go To Special, choose the Constants button and if we're only concerned with numbers here or values, let's uncheck the box for Text, and Logical, and Errors.

And as we click OK, we see the cells that are highlighted. If we want to make sure that they stay highlighted by a way of a color, then we'll go to the HOME Tab, the Fill Color Font, the arrow to the right and choose the color that we think will work best in this particular example. And we like the light green, maybe a little bit lighter, something like that. Recognize now that all these cells are selected and they have color, a slight difference and is not critical. If I click in cell A1, it will no longer be highlighted, but the color will be there.

So that's all we want our macro to do. Every time we execute this macro, we want to select all the cells that have numbers and apply a light green background, and then go to cell A1, although we could go to any cell. So we finished recording the macro. We can stop by pointing to the box just to the left to the word READY in the lower left corner of the screen in the status bar, Stop Recording. Let's try this in a different worksheet. We got the active cell anywhere here; we want to highlight those value cells and the keystroke shortcut I used, Ctrl+Shift+V. It works great.

What happens if we start to record a few more macros and a few more and a few more? We probably run out of meaningful keystroke shortcuts, if the letters were that meaningful, but we might want to be able to get to our macros in a different way. So I'll also confront this idea. What if we didn't want the macro to run? We ran it by mistake, maybe I did that here. Can we undo a macro? No we can't.Now the Undo arrow might look active, and you might click the drop arrow here, and if you've just recorded the action here, you might say, oh, I'll just undo it. Well that takes us back to here.

And we can't really undo what happened here. What we did here ultimately was just to apply color, so we certainly manually could do that. But the idea that you can't undo a macro is a critical thought. What if your macro deleted data? And I would strongly suggest that at least for a while, you don't write macros that delete data. You can't just casually say, well I'll come back and undo it. What you might need to do is close the file and not save it. What if you've done a lot of other good things in the meantime? Well you're going to loose all those too. So you want to be really careful with the idea that you can't undo what a macro does.

In other words, you can't reverse the steps Now in this case, lets imagine that I don't want the color there, we'll just get rid of the color. So I'll highlight the cells and easily by way of the HOME tab, go to the Fill Color bucket, choose No Fill. Now after doing some other things and coming back here, now I do want to run my macro. The one that highlights the number cells, maybe I forgot the keystroke shortcuts. So what do we do, if we forget a keystroke shortcut? Go to the VIEW tab, choose the drop arrow for Macros, go to View Macros.

I have only one macro here; there it is. I'll click it and we have the option to the right Run. It certainly isn't fast, but it's our fallback method. If it's one of those longer macros that manipulates a lot of data and takes two or three minutes, well we've saved a good deal of time, no question about it. Here's another thought. What if we want to change the keystroke shortcut? Once again go back to the same location on the VIEW tab click the drop arrow for Macros, View macros, here's the macro we're working with. We go to Options and change the keystroke shortcut.

And this is also where we go, if we didn't initially have a keystroke shortcut, we can assign it now, or if we want to delete the keystroke shortcut. Maybe we want to create another macro that's going to use this shortcut key. And so we see, we can easily change the keystroke shortcut or add it or delete it. In this case, we don't want to do any of those things. For certain macros, perhaps like this one that we think we might want to use often, we can also get to this in a different way. We can add a button to the Quick Access toolbar.

This is the set of buttons typically above the ribbon in the upper left-hand corner of your screen. It possibly is below the ribbon. No matter, where it is, if you Right-Click it, you can then choose Customize Quick Access Toolbar. And then in this dialog box called Excel Options, Choose commands from, click the drop arrow and choose Macros. Now you might or might not be seeing what I'm seeing here on the screen. Those are system type macros, but somewhere in here, you should see if you have created a macro, the name of the macro that you created.

There's the one I just created, let's add this to the Quick Access Toolbar. Maybe you're a little picky and you say, I don't like that icon. Well, you can come down here and modify, you've got 181 choices and I don't think anyone of them suggest exactly what we're trying to do here but I'll just choose a green box. There we go, OK. And as I click OK, look in the upper left corner of the screen, we now have that icon. We might leave it here for a long, long time, maybe forever if we use this often. It's going to be there no matter which workbook is open, provided the next exit from Excel is a normal one, so it will be there all the time.

And whether this workbook is open, it won't make any difference whatsoever. So we might go over to this worksheet right here and click this button, it highlights the cells that have numbers. It works easily and dates by the way are considered values, that's why they're highlighted here. Once again, can I undo? We'll not really to do. I can certainly remove the colors in other ways here; I can highlight all this data here, I'll go across here and get rid of the colors that way. It's like I also got rid of the colors up here, we won't worry about that.

But again, it brings back the idea that you can't really undo what a macro has done. You can certainly take manual steps to undo the effect. Now there's another possibility here for running macros. Even though this macro that we just saw is ideally designed to work in this workbook, that workbook, there could be situations where you want a macro to run right here by way of a button. And so we could create a button and there are any number of different ways to do this. One way can be, we can go to the INSERT tab and go to the Shapes icon for example and I'll just pick one of these at random, how about a rounded rectangle and I'm just going to draw this on the screen here; and type in Highlight Number Cells.

It doesn't have to match the wordings exactly of the macro, so Highlight Number Cells. And do all the formatting things that you might want to do with this. You can make it bold, bigger, all that sort of thing, not too critical there, but just to show we can do that too. But the key step next would be to Right-Click here and Assign Macro. So we're going to assign a macro to this button. For the moment we have only one, there it is right there. We'll click OK. Now we're still in edit mode, we might want to shrink this, do other things with it, whatever.

As we click away from it, in the future, anytime we slide the mouse over it, we see the pointer finger. This will activate the macro and what's it going to do here? It highlights the value cells and makes them green. And so we see one more way to activate a macro. We can also do this with icons and pictures too; this is just a simple example with a shape. So the way we make a macro work, and again the terms Playback, Run, Execute are all used synonymously is simply to use a keystroke shortcut, probably the most common way when you're getting started.

But ultimately by way of a button in the Quick Access Toolbar as we saw, and most recently by way of an icon or a shape on the worksheet.

Show transcript

This video is part of

Image for Excel 2013 Essential Training
Excel 2013 Essential Training

82 video lessons · 76799 viewers

Dennis Taylor
Author

 
Expand all | Collapse all
  1. 1m 6s
    1. Welcome
      43s
    2. Using the exercise files
      23s
  2. 29m 37s
    1. What is Excel used for?
      1m 49s
    2. Using the menu system
      4m 30s
    3. The Quick Access Toolbar
      4m 41s
    4. The structure of a worksheet or workbook
      3m 41s
    5. Using the Formula bar
      1m 43s
    6. Using the Status bar
      2m 24s
    7. Navigation and mouse pointers
      2m 20s
    8. Shortcut menus and the Mini toolbar
      3m 24s
    9. Using the built-in help
      2m 54s
    10. Creating new files
      2m 11s
  3. 24m 1s
    1. Exploring data entry and editing techniques
      4m 41s
    2. Entering data with AutoFill
      4m 6s
    3. Working with dates and times
      3m 32s
    4. Using Undo and Redo
      4m 50s
    5. Adding comments
      2m 55s
    6. Using Save or Save As
      3m 57s
  4. 30m 7s
    1. Creating simple formulas: Totals and averages
      5m 25s
    2. Copying a formula for adjacent cells
      2m 54s
    3. Calculating year-to-date profits
      3m 9s
    4. Creating a percentage-increase formula
      4m 7s
    5. Working with relative, absolute, and mixed references
      4m 7s
    6. Using SUM and AVERAGE
      3m 25s
    7. Using other common functions
      7m 0s
  5. 46m 7s
    1. Exploring font styles and effects
      4m 7s
    2. Adjusting row heights and column widths
      3m 37s
    3. Working with alignment and Wrap Text
      4m 2s
    4. Designing borders
      3m 26s
    5. Exploring numeric and special formatting
      5m 36s
    6. Formatting numbers and dates
      4m 31s
    7. Conditional formatting
      4m 21s
    8. Creating and using tables
      9m 59s
    9. Inserting shapes, arrows, and other visual features
      6m 28s
  6. 20m 40s
    1. Inserting and deleting rows and columns
      4m 52s
    2. Hiding and unhiding rows and columns
      4m 2s
    3. Moving, copying, and inserting data
      5m 42s
    4. Finding and replacing data
      6m 4s
  7. 17m 51s
    1. Exploring the Page Layout tab and view
      7m 20s
    2. Previewing page breaks
      4m 56s
    3. Working with Page Setup and printing controls
      5m 35s
  8. 30m 30s
    1. Creating charts
      4m 36s
    2. Exploring chart types
      7m 47s
    3. Formatting charts
      5m 42s
    4. Working with axes, labels, gridlines, and other chart elements
      5m 35s
    5. Creating in-cell charts with sparklines
      6m 50s
  9. 12m 49s
    1. Freezing and unfreezing panes
      2m 39s
    2. Splitting screens horizontally and vertically
      4m 48s
    3. Showing necessary information with the Outlining feature
      5m 22s
  10. 23m 0s
    1. Displaying multiple worksheets and workbooks
      4m 17s
    2. Renaming, inserting, and deleting sheets
      2m 23s
    3. Moving, copying, and grouping sheets
      3m 39s
    4. Using formulas to link worksheets and workbooks
      6m 1s
    5. Locating and maintaining links
      6m 40s
  11. 20m 25s
    1. Using IF functions and relational operators
      3m 43s
    2. Getting approximate table data with the VLOOKUP function
      7m 6s
    3. Getting exact table data with the VLOOKUP function
      4m 42s
    4. Using the COUNTIF family of functions
      4m 54s
  12. 23m 50s
    1. Unlocking cells and protecting worksheets
      7m 50s
    2. Protecting workbooks
      2m 40s
    3. Assigning passwords to workbooks
      4m 41s
    4. Sharing workbooks
      4m 7s
    5. Tracking changes
      4m 32s
  13. 28m 32s
    1. Sorting data
      6m 9s
    2. Inserting subtotals in a sorted list
      8m 25s
    3. Using filters
      6m 16s
    4. Splitting data into multiple columns
      5m 4s
    5. Removing duplicate records
      2m 38s
  14. 35m 2s
    1. Creating PivotTables
      8m 36s
    2. Manipulating PivotTable data
      9m 47s
    3. Grouping by date and time
      6m 0s
    4. Grouping by other factors
      2m 33s
    5. Using slicers to clarify and manipulate fields
      4m 7s
    6. Using PivotCharts
      3m 59s
  15. 23m 29s
    1. Using Goal Seek
      6m 8s
    2. Using Solver
      6m 34s
    3. Using Scenario Manager
      6m 11s
    4. Using Data Tables
      4m 36s
  16. 24m 31s
    1. Definition and examples
      6m 48s
    2. Creating a simple macro
      7m 0s
    3. Running a macro
      10m 43s
  17. 29s
    1. Next steps
      29s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ .

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Excel 2013 Essential Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member ?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferences from the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.