VBA code modules

Description

These are a collection of modules that I have used in VBA projects. They are all functions, not classes, and usually incomplete - I have just created the ones I needed.

modGeneric.bas: generic functions for any VBA project. In particular:

  • Array convenience functions, such as ArrayPush(), ArrayPop(), ArraySearch() ArrayJoin(), Quicksort algorithm for arrays
  • Text utilties e.g. Replace(), InStrR() (InStr that searches from the right)
  • Type casting functions that don't throw errors e.g. CIntF() is identical to CInt() but doesn't throw any errors, instead returning a sensible default (zero)

modExcel.bas: some simple functions that are Excel only.

  • cell and range functions: often just written to avoid error handling code in other functions e.g. RangeExists(s as String) provides an easy way to check for a named range without errors.
  • Some file routines:
    save a workbook, asking for a filename and checking if it already exists
    retrieve a value from a workbook without opening it (neat trick!)

modRegistry.bas: registry key manipulation. A number of wrappers on Windows API calls to make creating, retrieving and setting registry keys easy. Currently only a limited number of types of data are supported.

License

All the files come under a BSD license, included in each file.

Download

Download codebank, release 1, zipped

Contents:

modGeneric.bas - version 0.9
modExcel.bas - version 0.1
modRegistry.bas