Showing posts with label Excel Macro. Show all posts
Showing posts with label Excel Macro. Show all posts

How to Create a Macro-Enabled Workbook


Welcome to my Tutorials. 


In this Tutorial I will teach you how to create a Macro-Enabled Workbook within Excel 2010. 


A Macro-Enabled Workbook is used when the user wants to create and use macros within their workbook.  


Step 1: Begin by opening Excel 2010.
If you already have Excel 2010 open you don't need worry about opening it again.
Step 2: Create a macro
Technically you don't need a macro to create a Macro-Enabled Workbook. However, why would you make it Macro-Enabled if you had no macros?

For the purpose of this tutorial I will assume that you already know how to create a macro. If you need help creating a macro feel free to read my How to Create a Macro tutorial.

Now that we have Excel 2010 open and have created a macro we are ready to save the workbook as a Macro-Enabled Workbook.
Step 3: Save the workbook as Macro-Enabled Workbook

Open File menu.



















Select Save (This will open the Save As window). 

   











 




Select File Address.









 


Enter File Name.








Change the Save As Type to Macro-Enabled Workbook.








Select Save.
Congratulations.  You have created a Macro-Enabled Workbook. For a complete list of all my macro tutorials open Workbook Tutorials.

 

How to Create a Macro

Welcome to my Macro Tutorials.  In this tutorial I will teach how to create a macro. For a complete list of all my macro tutorials feel free to check out my Macro Tutorials.


There are two ways to create a macro in Excel 2010.
  1. First you can select Create from within the Macro Window. This will only create a blank macro with no purpose until you edit.  This is primarily used if you are familiar with the programming language used to create macros.
  2. The other way to create a macro within Excel 2010 is by using the Record command located on the Macro Menu in the View Tab.
 For the purpose of this tutorial we will use the second option.

Select View from the ribbon tabs.
View Tab



















Select the Macro Menu drop down arrow to open the Macro Menu.
Macro Menu - Record Macro





















Select the Record Macro. This will open the Record Macro Window.
Record Macro Window





















In this window you have the option to change the macro name, create a shortcut key and decide where you want to store your macro and provide a description.  For the purpose of this tutorial the only thing that matters is the name.  You can select what ever Excel chose for your or you can create you own name it doesn't matter as long as you understand that you don't want to create to macros with the same name.
 Select OK.
This will begin to record your macro.  Anything you do in within Excel from now until you select Stop Recording from the Macro Menu will be saved to this macro. Perform a few functions.  Change a cell color, add data, it doesn't matter what it is for the purpose of this tutorial. 
Now reopen the Macro Menu.
Macro Menu - Stop Recording


















 


Notice now Record Macro  has been replaced by Stop Recording.  This is how you will tell you macro to stop recording everything you do in Excel.
Select Stop Recording.

Congratulations.  You have created a macro.


How to Edit a Macro

Welcome to my Macro Tutorials.  For a list of all my Macro Tutorials feel free to check out my Macro Tutorials.

In the previous tutorial we created a new macro named GoodJob. In this tutorial I will teach you how to edit that GoodJob macro. If you have not been following along you just need to make a new macro named GoodJob.  If you don't know how to make a new macro feel free to read How to Create a Macro.


Lets Get Started.


Step 1: Open the Macro window.

Macro Window
Step 2: Select GoodJob from the list of macros Names.
Step 3: Select Edit to open the Visual Basic for Applications window.


Visual Basic for Applications Window

Step 4: Enter MsgBox "Good Job" inside GoodJob VBA Procedure outlined in red below.

Congratulations.  You edited a macro.  For the purpose of this tutorial you don't need to know what MsgBox "Good Job" means. Instead all you need to understand is that everything you want to have the macro run needs be between the Sub and End Sub lines.


In the next tutorial I will teach you How to Run a Macro.

How Does a Macro Work?


Welcome to my Macro Tutorials.  In this tutorial I will teach how a macro works. For a list of all my macro tutorials feel free to check out my Macro Tutorials.

Macros use a programming language called VBA.  VBA stands for Visual Basic for Applications.  VBA is an extension of the Visual Basic programming language designed to be used with applications such as Microsoft Office products.

When a macro is created a VBA Procedure is created.  A VBA Procedure is like a set of instructions for the macro.  Without the VBA Procedure or if the VBA Procedure name does not match the name of the macro, then the macro will not work properly.

These VBA Procedures are stored in a VBA Module within that workbook.  If no module already exists within the workbook then a VBA module is created. If this module is deleted then the Macros will be deleted too.


What is a Macro?

Welcome to my macro tutorials. For a list of all my macro tutorials feel free to check out my Macro Tutorials.

In this tutorial I will show you what a macro is.

A Macro is a custom command created by users to perform a specific function.  Ideally macros are designed to combine multiple commands into one command.  Whether you create a macro for a single command or a combination of 100 commands, the best reason to create and use macros is the ability to run them from any where within your application.

Example: 
Say you want to create a new worksheet you can create a Macro.  You can also use the same macro to name the worksheet after it is created.

In the next tutorial I will teach you How a Macro Works.