Codematic Excel developers logo
Codematic spreadsheet-excel development image

Rapid Application Development / Advanced Excel Development

Products for Excel
Commercial Products:
  - Classic Ribbon
  - Alt-FileSearch
  - Password Remover
Spreadsheet Quality Products
Free Products
Excel Development
Excel Development Index
Excel VBA
- VBA IDE (editor)
- VBA Training
- VBA Best Practice
- VBA Performance
- COM Performance
- VBA Security
Excel and Databases
Excel and Pivot Tables
Excel Add-ins
Worksheet Functions
Excel and xlls
Excel (in)security
Excel testing
Excel and .net
Excel External Links
Excel Developer Types
Professional Excel Development
Excel 2007
Excel 2010
Excel Development Archive
Spreadsheet Services
Spreadsheet Development
Spreadsheet Migration
Spreadsheet Maintenance
Spreadsheet Review
Spreadsheet Management
Excel User Confs
Consultant Profile
Book Reviews
Site Map

Spreadsheet Quality

Spreadsheet Design Concepts Series

VBA Connection

  • VBA UDFs should get all range info via parameters
  • Where (non UDF) VBA uses worksheet ranges, these should almost certainly be named ranges.
    • Sheet1.Range("Inflation").value = 0.02, or Sheet1.[Inflation].value = 0.02, rather than
    • Sheet1.[C5].value = 0.02, which may become invalid if rows or columns are inserted or deleted
    • strInflationRange = "C5" is just as bad - it creates a hidden dependency that must be manually updated when worksheet changes (poor coupling)
  • Variable and routine names:
    • Use very meaningful names (8-30 chars length)
    • Use a simple naming convention (matched pairs)
    • Use scope prefixes (g, m), and minimise it
    • Don't have to use data type variable prefixes (s, str, l, lng etc) (see .net advice)
    • avoid abbreviations
  • Don't use code comments demo make code ultra clear instead
  • Option Explicit on
  • Avoid Application.Run (non VBA - breaks error management)
  • routines 1 screen long max
  • 3-4 levels of nesting max
  • Use source control

Fuller information about VBA Best Practice (according to Codematic, of course - everyone has their own view) is here.

Of course all this is great in theory, but one of the key elements of professionalism is knowing when to go against so called best practice.



Upcoming Events:

25 January 2012 - UK Excel Developer Conference - London

Products for sale:


Office 2007 FileSearch replacement logo

New information about the missing FileSearch feature in Office 2007 and details of our pragmatic solution (Current price GBP 30.00)


worksheet password remover logo

Instant Excel worksheet protection remover and password recovery (Current price GBP 15.00)

Classic Ribbon Tab

classic ribbon for office 2007 logo

Add Excel 97/2000/2002/2003 compatible menu structure to Excel 2007
(Current Price GBP 10.00)


Products coming soon:

Link Manager

(Find and control external links in Excel Workbooks)

Due by Q1 2111.

XLAnalyst Pro

(Excel VBA based spreadsheet auditing tool)

Due before the end of 2111.

This page was last reviewed on December 21, 2011

©Codematic Ltd 1999-2011