|
|
| Back to Excel Homepage | Excel VBA - Reference Guide |
|
Menu Writing macros
Other links
|
Start by writing a task list of the step you wish to capture and use this as your checklist to help cover all actions required and in the correct order. Define your task1. Define the task you wish to program. 2. The overall task must be broken down into smaller tasks. 3. The program consists of a set of instructions or code, which the computer will follow. 4. The order in which you place these statements is very important. Layout of procedures
The blue text represents the procedure starting and ending signatures The green text represents the narrative/comments for documentation purposes which are excluded from the procedure. All procedures must have starting signature and ending signature. Pseudo codeWrite the program out in plain English to explain what is going to happen. sub formatting() bold italic underline end sub
Calling a procedure (formatting) sub start() select cells A2:A10 formatting select cells B1:G1 formatting end sub Writing macros from scratchThe following macro will select Sheet 1 and type January into cell A1 and 100 into cell A2.
1. Create a new blank workbook. 2. Click on the Developer tab, click Visual Basic icon. 3. In the VBE window, click on the Insert menu and select Module.
4. Type the VBA code into the module and test.
Note that the text 'January' is entered with speech (double-quote) marks, as it is a piece of text, where as the number 100 is entered without.
|
Tip: Alt + F11 function keys switches between Excel and VBE window.VBA Keywords: ActiveCell, Range, Worksheets, Select. |
|
© copyright 2010 TP Development & Consultancy Ltd, All Rights Reserved. All trademarks are copyrighted by their respective owners. Please read our terms of use and privacy policy. |