Page 228 - CITS - Computer Software Application -TT
P. 228

COMPUTER SOFTWARE APPLICATION - CITS




           Writing a macro in Visual Basic Editor
           The Visual Basic for Applications (VBA) Editor is the place where Microsoft Excel keeps the code of all macros,
           both recorded and written manually.
           In the VBA Editor, you can not only program a sequence of actions, but also create custom functions, display your
           own dialog boxes, evaluate various conditions, and most importantly code the logic! Naturally, creating your own
           macro requires some knowledge of the structure and syntax of the VBA language, which is beyond the scope of
           this tutorial for beginners. But there is nothing that would prevent you from reusing someone else's code (say, the
           one you've found on our blog :) and even a complete novice in Excel VBA should have no difficulties with that!
           First, press Alt + F11 to open the Visual Basic Editor. And then, insert the code in these two quick steps:
           1  In the Project Explorer on the left, right-click the target workbook, and then click Insert > Module.
           2  In the Code window on the right, paste the VBA code.
           When done, press F5 to run the macro.


























           How to run macros in Excel
           There are several ways to start a macro in Excel:
           •   To run a macro from a worksheet, click the Macros button on the Developer tab or press the Alt + F8 shortcut.
           •   To run a macro from the VBA Editor, press either:
           •   F5 to run the entire code.
           •   F8 to go through the code line-by-line. This is very useful for testing and troubleshooting.
           Additionally, you can launch a macro by clicking a custom button or pressing the assigned shortcut.
           How to enable macros in Excel
           Because of security reasons, all macros in Excel are disabled by default. So, to use the magic of VBA codes to
           your advantage, you need to know how to enable them.
           The easiest way to turn on macros for a specific workbook is to click the Enable Content button in the yellow
           security warning bar that appears at the top of the sheet when you first open a workbook with macros.




















                                                           215

                             CITS : IT&ITES - Computer  Software Application - Lesson 63 - 77
   223   224   225   226   227   228   229   230   231   232   233