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

Creating a simple macro

From: Excel 2013 Essential Training

Video: Creating a simple macro

After you have identified a certain sequence of actions that you would like to automate in the form of a Macro, it's time to learn how to actually record a Macro. The process has begun already because you've either written down or you know those steps you want to take. For example, we've decided that it's really handy to be able to click on a cell here and when it's questionable, we want to apply a special format. A format that might include using some of the features on the HOME tab like a background of yellow, a red font and a few other features as well, we don't want to go through those steps manually each time.

Creating a simple macro

After you have identified a certain sequence of actions that you would like to automate in the form of a Macro, it's time to learn how to actually record a Macro. The process has begun already because you've either written down or you know those steps you want to take. For example, we've decided that it's really handy to be able to click on a cell here and when it's questionable, we want to apply a special format. A format that might include using some of the features on the HOME tab like a background of yellow, a red font and a few other features as well, we don't want to go through those steps manually each time.

So, the process of recording a macro also begins with this thought. Is the macro we are about to record, designed only for this workbook or might we want to use it elsewhere? Let's imagine for the moment that we're only going to use this macro in the current workbook. A bit later we might change our minds about that. It is something we need to think about though because certain macros could be used in any workbook. Let's start by going to the VIEW tab in the ribbon. The right most button, Macros has a drop arrow, let's click it, and we see the choice Record Macro.

And here's a dialog box. We need to give our Macro a name. Ideally it should be a meaningful name, the name cannot begin with a number, it cannot contain spaces, some special characters work some don't. It's best to stay away from them. The naming of this macro ideally would be something like Apply Format or Highlight Cells, something like that. How about Highlight Cells, that's an easy one. Now I cannot put a space in but I can use either underscore or maybe I'll simply switch case, either way. So underscore is okay, that's fine, Highlight_Cells.

We can give it a longer name if we wanted too. Macros often have keystroke shortcuts and that's a favorite way, particularly when you're just getting started with this feature. Long term, sometimes you say, well I've got so many macros, I forget which one is which. I don't remember the keystroke shortcut and so on. So at times you might grow weary of this concept. But what can we choose for a shortcut key? We have only 52 choices, any of the lowercase letters, any of the uppercase letters. Now if I think C here for cells sounds like a good idea maybe, but a lot of you now that Ctrl+C, one of the most widely used keystrokes of all in Excel is for Copy.

If we use Ctrl+C for this Macro, we will no longer be able to use Ctrl+C for Copy, so that isn't a good choice. Do you use Ctrl+H, that means Replace, well you might, but if you don't, well you could possibly use that one. There might be a tendency here to use uppercase letters. And all I need to do is hold down the Shift key. So I'm about to use Ctrl+Shift+H. I'm holding down Shift key right now, pressing the letter H. The word Shift pops in automatically. Now earlier, I'd mentioned this idea of using the macro in this workbook only.

If that's the choice we will click the arrow here and choose This Workbook. If you do want a Macro to be available for all workbooks at all times, you store it in a location called Personal Macro Workbook and we'll get to that in a bit. This time we're saying the macro we're writing, at least for awhile, it maybe always will be stored in this workbook. Now there's a description panel here and for small macros, typically we don't say anything, but longer macros, it's really helpful to provide a description.

And you will find it useful yourself when you look a Macro that you wrote last year or a while ago, and certainly others if they happen to be using this macro will want to know what the Macro does. Sometimes the name doesn't do it enough justice. So you can certainly provide a description here. So in this case, the macro is short enough. The macro name itself does a pretty good job of describing it. We're about to click Okay, but before we do, let's talk about what is about to happen. When we click OK, we will be in a mode of recording a series of actions.

And so the idea is we want to stay focused. We should know exactly, what it is we want to do, perhaps we've written down the steps. In a lower left corner of the screen, in the status bar, we see the word READY, but we're about to see something else there as we click OK. Now in the lower left corner, there's a little box next to the word READY. If we slide over it, the pop-up reads A macro is currently recording, click to stop recording. And we can certainly stop the process right there. We can also go back by way of the VIEW tab in the ribbon to the Macros arrow and choose Stop Recording up there as well, but we're in recording mode right now.

So if I'm scrolling up and down here, that's going to be in the macro. It's practically meaningless, we won't see it, but the idea is we don't want to be taking actions here that will be in the macro. Behind-the-scenes, what we don't really need to get into is the fact that every action we take is actually translated into the programming language VBA, Visual Basic for Applications, and learning about that feature takes a good deal of time and requires a different course. In this course, all we need to focus on is the idea that when you turn on the macro recorder, the steps that you are recording can be used later instantly with a keystroke shortcut.

And ultimately maybe even a new button in the Quick Access toolbar. So we're in this recording mode right now, let's apply those features that we want to have happen every time we use this macro in the future. So we go to the HOME tab and we've used this recently, so the yellow is still there, we want to use the fill color yellow, fine. We want to use red font, that's good; we want to make it bold, it's good and let's say we apply the Border feature as well here, the Thick Box Border. Remember we want that to happen every time we run this macro in the future.

And those are all the steps that we need. The question might have entered your mind; will this work if we highlight multiple cells? Well, it will. You don't necessarily know that ahead of time, but it will, and we can use this on one cell or different cells even. So we've essentially recorded all there is to record, and we're done. So we can end this by either going to the box in the lower left corner, that's certainly straightforward. Less straightforward but just to show that it's there, VIEW tab, the arrow for Macros, Stop Recording either way.

So we've recorded this. Let's go to a different location, let's try this Ctrl+Shift+H, it works. Can we try it on a few cells? Again, recognizing the reason we set this up is because we recognize that some of these cells need to be looked into. I think both of those are incorrect. Maybe Ctrl+Shift+H, looks like the feature works on multiple cells as well. So I've seen an example here of how recording a series of actions can easily be executed by pressing that keystroke shortcut.

And you will hear the term Playback, Execute, Run; they all mean the same thing. The idea of making the macro, do what it needs to do with just a single action.

Show transcript

This video is part of

Image for Excel 2013 Essential Training
Excel 2013 Essential Training

82 video lessons · 69914 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 preferencesfrom 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.