Wednesday, February 16, 2005

Our first look at VBA

Hopefully everyone has had a chance to finish the Excel revision exercise from last week! We're going to jump straight in this week and record our first macro (as we didn't get time to do this last week!)

To start us off, right-click on this link to Excel VBA: No experience necessary - Lesson 1 and choose the option to open in new window. You can start following this tutorial yourself in Excel, but unless you're really confident stop when you get to the heading "Loopy" (We'll come back to this later!).

Once you get up to the "Loopy" heading, try the following:
  1. Go back to the VBA editor (Alt-F11) and see if you can modify your Example1 macro so that, instead of putting "Hello Excel" into the cell, it puts "Hello [your own name]". How did you know which line of the VBA code to change? Can you explain what each line of your VBA code is doing? Run your macro again to make sure it works.
  2. Practise what you've learned by recording a new macro (call it 'Example2'). Try doing a few random things (entering your name into a cell, changing the formatting of a number to percentage etc.) before stopping the macro from recording. Now go back into the VBA editor and see if you can understand what each line is doing (try explaining it to someone around you!) Can you remember how to run your macro? Give it a go!
Time to add a new entry to your blog! If you go to the Blogger site, login, then see if you can remember how to create a new post (something like "My first VBA experience!"). If possible, make sure you cover the following points (all from the tutorial):
  • What does VBA stands for?
  • What is it good for?
  • How did you get to the VBA editor from Excel?
  • What's the easiest way to figure out how write the code to do something in Excel VBA?
  • How was your first experience of creating a computer program in VBA?
Right! Enough VBA for the moment!

0 Comments:

Post a Comment

<< Home