Macros Programming in MS Excel, 2 Days Training Workshop from - 10.00 am to 5.00 pm
Why Macros are important: Macro is a collection of commands that you can apply with a single click. They can automate almost anything you can do in the program you’re using and even enable you to do things you might not have known were possible. Macros are programming, but you do not need to be a developer or even have programming knowledge to use them. Most macros you can create in the Office programs are written in a language called Microsoft Visual Basic for Applications, usually referred to as VBA. VBA macros are the type addressed in this article. Macros save time and expandthe capabilities of the programs you use every day. They can be used to automate repetitive document production tasks, streamline cumbersome tasks, or create solutions such as automating the creation of documents that you and your colleagues use regularly.
Topics to be covered
1) Create a Macro: To create a macro in Excel VBA, first activate Excel Visual Basic. Next, you can create a command button and assign a macro to the command button.
2) Excel Macro Recorder: The Excel Macro Recorder is a very useful tool included in Excel VBA. With the Excel Macro
Recorder you can record a task you perform with Excel. Next, you can execute the task over and over with the click of a button which can save you a lot of time. This chapter explains the ins and outs of the Excel Macro Recorder.
3) Macro Security: Setting up your macro security settings correctly is essential to protect yourself against potential viruses. Make sure your macro security settings are set up correctly so no harm can be done to your computer.
4) Visual Basic Editor: Learn how to launch the Visual Basic Editor and get the best configuration of the Project Explorer and the Code Window in your Excel Version. The Visual Basic Editor is the starting point for creating macros in Excel VBA, so it is important to get this configuration right.
5) Macro Comments: Add macro comments to your Excel VBA code and your code will be easier to read as program size increases.
6) MsgBox: The Message Box is a dialog box you can have appear to inform the users of your program.
7) Macro Errors: Dealing with VBA-errors can be quite a challenge. This chapter provides you with a simple tip to deal with these errors.
8) Debug Macros: Before you execute your VBA-code you can first debug your macro. This way most of the errors can be corrected before you execute your code.
9) Objects, Properties and Methods: In this chapter you will learn more about Excel VBA objects. An object has properties and methods. Excel Visual Basic is a semi-object oriented programming language. Learn more about the object hierarchy of Excel Visual Basic.
10) Workbook and Worksheet: In this chapter you will learn more about the Excel VBA Workbook and Excel VBA Worksheet object. You will see that the Worksheet and Workbook object have properties and methods as well, such as the count property which counts the number of active workbooks or worksheets. The Workbook and Worksheet object are commonly used in Excel VBA. They are very useful when your macro code has to be executed on different workbooks or worksheets.
11) Application Object: The mother of all objects is Excel itself. We call it the Application object. The application object gives access to a lot of Excel related options.
12) Variables: Excel VBA uses variables just like any other programming language. Learn how to declare and initialize an excel vba variable of type Integer, String, Double, Boolean and Date.
13) String Manipulation: There are many functions in Excel VBA we can use to manipulate strings. In this chapter you can find a review of the most important functions.
14) Calculate: Calculate with Excel VBA and add, subtract, multiply and divide values just like you are used to doing in Excel.
15) If Then Statement: In many situations you only want Excel VBA to execute certain code lines when a specific condition is met. The If Then statement allows you to do this. Instead of multiple If Then statements, you can use Select Case.
16) Cells: Instead of the more common Range object we could also use Cells. Using Cells is particularly useful when we want to loop through ranges.
17) Loop: Looping is one of the most powerful programming techniques. A loop (or For Next loop) in Excel VBA enables you to loop through a range of data with just a few lines of code.
18) Logical Operators: Do you want to execute code in Excel Visual Basic when more conditions are met? Or just one? Or none? Logical operators are what you need! Logical operators such as And, Or and Not are often used in Excel VBA.
19) Range: The Range object which is the representation of a cell (or cells) on your worksheet is the most important object of Excel VBA. It has many properties and methods and they are essential to manipulate the content of your Excel worksheet. In this chapter you will discover the most useful properties and methods of the Excel VBA Range object. They enable you to obtain control over your Excel worksheet.
20) Events: This chapter teaches you how to program workbook and worksheet events. Events are actions performed by users which trigger Excel VBA to execute a macro. For example, when you open a workbook or when you change something on an Excel worksheet, Excel VBA can automatically execute a macro.
21) Array: An Excel VBA array is a group of variables. You can refer to a specific variable (element) of an array by using the array name and the index number.
22) Date and Time: Dates and Times in Excel VBA can be manipulated in many ways. Easy examples are given in this chapter.
23) Function and Sub: The difference between a function and a sub in Excel VBA is that a function can return a value and a sub cannot. In this chapter we will look at an easy example of a function and a sub. Functions and subs become very useful as program size increases.
24) Textbox: A textbox is an empty field where the user can fill in a piece of text. Learn how to draw a textbox on your worksheet, how to refer to a textbox in your Excel VBA code, and how to clear a textbox.
25) List box: A list box, is a drop down list from where the user can make a choice. Learn how to draw a list box on your worksheet and how to add items to a list box.
26) Combo box: A combo box is the same as a list box but now the user can also fill in his/her own choice if it is not included in the list. Learn how to draw a combo box on your worksheet and how to add items to a combo box.
27) Checkbox: A checkbox is a field which can be checked to store information. Learn how to draw a checkbox on your worksheet and how to refer to a checkbox in your Excel VBA code.
28) Option Buttons: Option buttons are the same as checkboxes except that option buttons are dependent on each other while checkboxes are not. This means that when you check one option button the other option button will automatically uncheck.
29) User form: It teaches you how to create an Excel VBA User form (also known as a dialog box). You can download the User form on this page as well.