Download the best tutorial, website and reference tool on Excel |
Lesson 5: Modifying Macros in the Visual Basic Editor |
Let's begin this chapter my modifying the VBA procedure that you have created with the macro recorder earlier. Open Excel, open the workbook "VBATest1.xls" and go to the Visual Basic Editor. Double click on Module1 in the VBA project window and the following code will appear in the Code window. Click in the code window and print the module for future refernece "File/Print/Current Module" |
Print this page and follow the instructions step by step. The Macro Recorder (MR) has a very special way to write code. The procedure above works so we could leave it alone but just to make it clearer let's make it simpler. You can replace each line of code yourself or copy/paste the entire new procedure below from this web page onto the old procedure in the VBE When
I started the Macro Recorder cell A1 was selected and I entered
34 in it. The MR writes
Line 2 and 3 of the procedure
read like this:
Line 4 and 5 of the
procedure read like this:
Line 6 and 7 of the
procedure read like this:
Line 8 to 12 of the
procedure read like this:
Line 13 to 25 of
the procedure read like this: |
The VBA procedure or macro called "Macro1" now looks like this: Sub Macro1() '
Macro1 Macro Range("A1").Select End Sub We will test it in lesson 6 |
Download the best tutorial, website and reference tool on Excel |
All rights reserved PLI Consultant Inc.