VBA HOME PAGE

Menu

Recording macros

Looking at the code

Ways of running macros

Where macros are stored

Reasons to write macros

Writing macros

Procedure types

Visual Basic editor (VBE)

Rules & conventions

Excel objects

Range/Selection objects

Object hierarchy

Object browser

Chart objects

Pivot Table objects

Formulas

Visual Basic Functions

Creating Add-Ins

Variables & constants

Object variables

Arrays

Collections

Message Box

VBA Input Box

Excel Input Box

Making decisions (If)

Making decisions (Case)

Looping (Do...Loop)

Looping (For...Loop)

With...End With blocks

User defined functions

Event handling

Error handling

Debugging

Creating User Forms

DAO/ADO Objects

Input/Output Files

 

Other links

Example code snippets

Userform input example

 

 

 

 

 


Visual Basic Editor

All macros can be edited and created from the Visual Basic Editor (VBE) application as mentioned earlier.

Standard Toolbar

Contains all the basic buttons to this window like save, switching to Excel and hide/show other windows.  There are other Toolbars available; Edit, Debug, User Form and Toolbox.

 

Object Box

This displays the name of the selected object chosen from the drop down box.

 

Procedure Box

This displays the name of the procedure or event of the object (i.e. worksheet).

 

Code Window (Module)

This is where you maintain the VBA code. One or more sub and function procedures are stored in this view and users manage macros across one or more modules.

 

Project Explorer

All the code associated with a workbook is stored in the ‘Project’ window.  This is automatically saved with the Workbook.

 

Like a workbook, the ‘Project Explorer’ contains all associated objects, which include worksheets, user forms and modules.

Macros are stored in either the sheet object or module object. Consider using the module object to store macros for general use in that workbook rather than a specific macro for a specific sheet.

By double clicking on an object or clicking the view code button at the top left corner of the ‘Project’ window, displays the objects code (macros associated).

 

Properties Window

Properties are characteristics of the selected object. 
This window allows you change these characteristics to a worksheet, workbook and user form.

This above window is task sensitive and therefore changes as you click from one control to another.

 

 Edit Toolbar

Select View, Toolbars and select the Toolbar required.

 

Edit Toolbar

1

Lists Properties/Methods box in a code window. This is task sensitive as it shows properties and methods to active keywords.

2

List Constants.

3

Quick Info displays a label for the active keyword or variable.

4

Parameter Info displays the syntax label of known keywords.

5

Complete word displays a scroll list box of keywords and completes the beginning of known types keywords.

6

Indent tabs once to the right.

7

Outdent tabs once to the left.

8

Toggle Breakpoint allows marking a line of code at which point a macro will stop.

9

Comment Block ‘rem’ the line (put an apostrophe at the beginning of the line).

10

Uncomment Block removes the ‘rem’ line.

11

Toggle Bookmark marks with a blue marker a piece of code so that scrolling between code lines is quick and simple.

12

Next Bookmark moves to the next bookmark.

13

Previous Bookmark moves to the previous bookmark.

14

Clear All Bookmarks clears all bookmarks.

 

There other toolbars that you may need to review and can be found via the View menu.

 

 


Next Topic: Rules & conventions

 

Want to teach yourself Access? Free online guide at About Access Databases

Tip: Use F5 function key to run a macro from the VB Editor.
Home | Terms of Use | Privacy Policy | Contact

© 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.