VBA – How to start?

Lesson 1 – VBA and Excel

What is VBA? – VBA is something great, if you are working more than 1 hour with MS Excel and MS Access. It is simply said a must for everyone, who earns his money with an office job. It is not difficult programming, but something very simple and fun. Let’s see 🙂 It does not even need installation! You can start NOW!

Open an empty file in Excel.
Press ALT and F11.
Think of all the missed opportunities. 🙂
Then you have this two screens. (Click to enlarge):
1 
 
 
 
 
 
 
 
 

 

 

In order to make it easy and quickly, you may use the key combinations in Excel WINDOWS key + Left Arrow and WINDOWS key + Right Arrow.
As a next step press on VIEW>MACROS>RECORD MACRO (as in the screenshot).
2 
 
 
 

 

Now is the funny part. Click YES on the dialog which appears.
Then start putting random things in Excel and take a look how it generates the code for them at the right part. This is what I have done:

3 
 
 

 

 

 

 

 

At some point you can go to the bottom left corner of the file and stop the recording.

4 
 
 
 
 
 
 

 

Once the recording is stopped, you may do the following:

Erase everything you have written in the Excel file. Go to Modules>Module 1 (see the picture).

5 
 
 
 
 

 

Press within the code (the yellow thing in the above picture)
Start pressing F8 and check out how the stuff you have erased is coming back. Furthermore, it is not only the written stuff, but also the correct selections and everything!
Now think how you can use this in your every day work! 🙂

Tagged with: , ,