VBA Best Practice There is a lot of information floating around about how to get various things done in VBA, how to make the best use, or sometimes just the most use of VBA and Excel. This section aims to add an element of Quality and Best Practices. These are just general guidelines, a professional developer will always assess the options and make the appropriate choice in their specific situation. These suggestions are specific to Excel VBA in commercial settings, many will not translate to other technologies or other settings. VBA Best Practice Series
High Quality Code - General 2
- Recognise when you move from procedure based design to module/object based (eg procs need to return >1 value, lots of parameters get passed all around)
-
Object Oriented designs can be useful, but can cost performance
-
The biggest factor on performance is design
-
Be aware of Excel/VBA limitations, and clear on its strengths
-
Use 'TODO' and maybe 'Enhancement' comments (don't release until TODOs cleared - (use edit find in project)
-
Use shift+F2 for definitions, F8, Shift+F8 and Ctrl+Shift+F8 (step out) and stop
-
Note compiler is weak compared to C++ (eg:won't catch assigning a string to a variable of type double)
-
Use code cleaner regularly
-
Differentiate style from quality
-
Use the most restrictive scope that works for variables and routines
|
|
Upcoming Events:
25 January 2012 - UK Excel Developer Conference - London
Products for sale:
AltFileSearch

New information about the missing FileSearch feature in Office 2007 and details of our pragmatic solution (Current price GBP 30.00)
wsUnprotector
Instant Excel worksheet protection remover and password recovery (Current price GBP 15.00)
Classic Ribbon Tab
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. |