Excel Macros or VBA Tutorial for Beginners (with Images)
This Introductory post/tutorial is for beginners who want to learn the basics of Excel Macros !
Before getting started with excel macros just two lines about Macros and VBA.
What is a Macro?
– A macro is a series of VBA commands and functions to perform a task.
What is VBA?
– VBA (Visual Basic for Applications) is a programming language that Microsoft Office (MS Excel, Word, Power Point, Access etc) applications uses.
An excel macro is a set of VBA commands and functions that automates the tasks you do in excel.
Set of VBA instructions = Macro = Automated task
The best part is you don’t have to know anything about VB or VBA to automate a task you do in excel or to create excel macros.
It is as simple as using a voice recorder in your mobile phone.
Click on start + record the task + click on stop = it’s done! Your macro is created!
Why don’t you try creating your first Excel Macro?
Let’s create a macro which fills Green color in your Excel cells. Follow the below steps.
Steps to create your first macro:
Step 1: Open a new Excel and go to the Developer tab then click on Record Macro from the Code section.
Step2: As soon as you click on Record Macro a pop-up window appears requesting you the following:
Macro name : GoGreen (Lets name our macro as GoGreen; Remember not to use any special characters or space.)
Shortcut key : For now lets leave it as blank.
Store Macro in : This gives you three options to save the macro in; current work book, Personal
Macro Workbook or in New Workbook. Let’s select the current workbook ie.‘This Workbook’
Description : My first macro to fill Green color in cells. (A small description about the
macro you are creating.)
After filling the details click OK.
As soon as you click OK, the Record Macro’s icon turns to a blue button and the same is visible at the bottom of the screen and that indicates macro has started recording; means from now what ever you do in excel will get recorded. This blue button is our Start and Stop button.(Even we can directly start recording macro by clicking this button rather than going to Developer tab and then Record Macro.)
Step3: Go to Home tab and click on Fill Color and from the list of colors displayed click on Green.
Step4: Click on Stop button (The Blue button mentioned above) to stop recording macro.
Now that you have recorded your first macro and you can run it by clicking Developer tab – Macros- Run OR Alt + F8 – Run. But wait a minute lets make it little more beautiful and convenient to use.
Go to Insert – Shapes and click on any shape which you like (I have selected Rectangle). Now your courser turns to a ‘ + ‘ shape that means you can draw a Rectangle in any part of your Excel.
After you draw a Rectangle, right click on it and click on Edit Text and name your shape as GoGreen. And once again right click on the shape and then click on Assign Macro..from the drop-down list.
After you click on Assign Macro, a pop-up window appears then select GoGreen from the Macro name filed and click OK.
You have successfully created your first macro and assigned a button to run that macro, start filling green color by clicking the GoGreen button.
Now that we have to learn how does this macro works. We will learn it from the next chapters. Before that two quick home works:
1. Open VBA editor and try to explore/understand the GoGreen Macro codings by yourself.(Developer tab – Macros – GoGreen – Edit)
2. Record another macro to NoFill the entire sheet and assign that macro to a different shape and name it as Clear all. So thatyou can keep playing with your macro; One to fill the color and another to clear the color.
You can download my free GoGreen Macro Workbook from the below link.
Download Free Macro Workbook
Automate Complex Tasks with Microsoft Excel VBA & Excel Macros (Real-World Projects included). Achieve More. Save time.
t will be a worth investment! And Right Now you can register with upto 80% Off
(Only when you click and join from here ⇊)
Unlock Excel VBA and Excel Macros
Do you mind if I quote a couple of your articles as long as I provide credit and sources back to your webpage? My website is in the exact same area of interest as yours and my users would certainly benefit from a lot of the information you provide here. Please let me know if this alright with you. Thanks a lot!
Great post, I conceive website owners should learn a lot from this weblog its rattling user genial . “Frisbeetarianism is the belief that when you die, your soul goes up on the roof and gets stuck.” by George Carlin.
Merely wanna remark on few general things, The website design is perfect, the subject material is really superb : D.
I like this website very much so much excellent information.
Found your short article quite interesting without a doubt. I really experienced reading through it and you also make fairly some very good factors. I’ll bookmark this web page for the potential! Relly excellent short article.
Found your article quite intriguing in truth. I really loved examining it and you simply make quite some great points. I’ll bookmark this web site with the long term! Relly good write-up.
I simply want to mention I’m very new to blogs and really savored your web page. Probably I’m want to bookmark your blog post . You definitely come with fabulous article content. Appreciate it for revealing your blog.
Sure Darla and Thanks for your inspiring comment!!
Excellent post at Introduction to Excel Macros |. I was checking constantly this blog and I’m impressed! Extremely useful information specially the last part 🙂 I care for such information a lot. I was looking for this certain info for a very long time. Thank you and best of luck.
As a Newbie, I am always browsing online for articles that can benefit me. Thank you
You are most welcome Samira!! and you can always ask me for articles on topics which you would like to know/learn.