Recording our first Excel VBA Macro!
Recording Macros in Excel isn't difficult at all... and the great thing is, we can start learning a bit about programming in Excel by getting Excel to do the programming for us!
The Excel macro recorder is the best teacher that you can have and will remain the best assistant for the rest of your life.Follow these instructions to create your first Macro:
- Start the Macro recorder
- In Cell A1, enter the value 25
- In Cell A2, enter the value 42
- And in A3, enter 56
- Set the font-size of A3 to 16.
- Set the background color of A2 to yellow.
- Stop the recorder.
After you've tested your first Macro a couple of times, see if you can make the following modifications to your code:
- Modify your code so that the value that is put into cell A2 is 999 instead of 42, re-run your macro to test it!
- Modify your code so that the font-size of cell A3 is set to 8 instead of 16, and again, re-run your macro.
- Modify your code so that the background colour of cell A2 is something other than Yellow. As usual, re-run your macro to make sure that your change worked!
- Challenge: See if you can add a button to your worksheet so that when you click on your button, your macro runs!
- Save your worksheet as VBAMacreExamples.xls
Some points you will want to file away in your mind:
- What does VBA stands for?
- Where or why is it used in Excel (and other applications)?
- 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?
- Why is Debugging useful?
0 Comments:
Post a Comment
<< Home