1 00:00:01,190 --> 00:00:07,280 In this video we're going to cover how to record a macro which is a very helpful tool when trying to 2 00:00:07,280 --> 00:00:12,770 quickly automate simple processes or when trying to find the right terminology to accomplish something 3 00:00:12,770 --> 00:00:19,980 in VBA to start we need to be on the developer tab of the ribbon under the code section. 4 00:00:19,990 --> 00:00:23,590 Go ahead and click on record macro. 5 00:00:23,650 --> 00:00:29,590 Now what recording a macro essentially does is record all of your clicks and interactions with Excel. 6 00:00:29,590 --> 00:00:35,630 And it turns them into a macro for you to run again in the future to execute those same actions. 7 00:00:35,740 --> 00:00:40,650 We'll go through an example of that shortly but first let's talk about this window that pops up. 8 00:00:40,900 --> 00:00:48,910 You have the option to enter a name so we'll go ahead and put recorded macro like so and this name will 9 00:00:48,910 --> 00:00:52,650 actually give us an error message but we'll talk about that in a minute. 10 00:00:52,690 --> 00:00:59,890 The shortcut key can be used to tie your macro to a combination of keys on your keyboard to run quickly 11 00:00:59,890 --> 00:01:06,340 and automatically the store macro dropdown is mainly intended for multiple workbooks being open at the 12 00:01:06,340 --> 00:01:09,640 same time so we can ignore that for now. 13 00:01:09,640 --> 00:01:14,830 Lastly you have the option to put a description of your macro in and that's to help other users know 14 00:01:14,830 --> 00:01:19,240 what this macro does without having to look at and understand the code. 15 00:01:19,240 --> 00:01:26,070 So let's go ahead and click ok and we see we get an error message that pops up their message says the 16 00:01:26,070 --> 00:01:28,540 syntax of the name is incorrect. 17 00:01:28,590 --> 00:01:32,260 In our case it's because we put a space in the middle of the name. 18 00:01:32,280 --> 00:01:37,800 Generally speaking it's best practice when coding to avoid unnecessary spaces and instead replace them 19 00:01:37,800 --> 00:01:39,000 with underscores. 20 00:01:39,150 --> 00:01:44,260 And there are several reasons for this which will be made clear in the details of coding and VBA. 21 00:01:44,310 --> 00:01:45,620 For now click OK. 22 00:01:45,630 --> 00:01:48,510 And change the name to recorded underscore macro 23 00:01:51,600 --> 00:01:52,790 and go ahead and click ok. 24 00:01:55,450 --> 00:02:00,640 Now we can see up here the record macros Button has actually turned into a stop recording button and 25 00:02:00,640 --> 00:02:05,290 that's where you'll go to click when you're done doing all of your actions and completing your macro 26 00:02:06,030 --> 00:02:09,490 to just give an example of what this might look like. 27 00:02:09,550 --> 00:02:17,690 Go ahead and click into any cell and type a click out of that so click back into that cell. 28 00:02:17,840 --> 00:02:25,400 Go to home and give it some sort of formatting whatever color whatever sized text whatever background 29 00:02:25,400 --> 00:02:26,540 color you'd like. 30 00:02:26,780 --> 00:02:29,600 Then go back to developer and click stop recording. 31 00:02:32,640 --> 00:02:39,940 Now if we click on our macros button here we can see we have a recorded macro that's showing up go ahead 32 00:02:39,940 --> 00:02:45,100 and close out of that and let's go take a look at what the macro actually looks like in order to do 33 00:02:45,100 --> 00:02:51,850 that on your developer tab click on the Visual Basic button to pull up the Visual Basic window under 34 00:02:51,850 --> 00:02:58,300 the modules folder in your project Explorer window you should see a module one double click on this 35 00:02:58,300 --> 00:03:04,080 to open it and we can see here this is our recorded macro. 36 00:03:04,190 --> 00:03:09,270 Now I'm not going to walk through the details of what each of these lines mean we'll cover the details 37 00:03:09,270 --> 00:03:16,920 of all of VBA and feature videos but to give you a general idea these lines selected the cell and made 38 00:03:16,920 --> 00:03:26,880 its value a these lines changed the background color of that cell to be yellow these lines changed the 39 00:03:26,880 --> 00:03:35,270 font to be red and these lines increased the size of that font and this end sub means that's the end 40 00:03:35,330 --> 00:03:36,800 of this particular macro. 41 00:03:37,310 --> 00:03:41,810 So just to give an example of what running this macro might look like. 42 00:03:41,960 --> 00:03:52,930 Go ahead and exit out of your VBA window Let's insert a new sheet down here under macros select recorded 43 00:03:52,940 --> 00:04:00,320 macro and click Run and we can see the system copied all of the actions that we had done previously 44 00:04:00,320 --> 00:04:04,980 on sheet 1 and did the same thing on this new sheet sheet too. 45 00:04:05,030 --> 00:04:10,970 So this was a very simplified example of when you might be able to use record macro but you should have 46 00:04:10,970 --> 00:04:16,460 a good idea now of how to use this tool to either get the terminology you need to accomplish something 47 00:04:16,460 --> 00:04:23,030 in VBA or to record a series of relatively simple small steps and try to automate your processes.