VBA - Visual Basic for Applications

The following method returns a Range object referneced by a NamedRange in an Excel worksheet. Motivation for this article is the fact that VBA does not handle possible errors in a NamedRange. If a referenced range contains errors even in formulas, the simple calll to RefersToRange of a NamedRange will fail.

In case you need the selected list item from a listbox, which only allows single selection the selected list item can be returned using the below source code.

Source Code

1
Me.listBox.column(0)

Where listBox is the name of the control element / the listbox as you defined it.

Me refers to a form a listbox is placed in.

The column index within a listbox is zero based.

If you have to delete all records from a table using Access VBA DAO, the following method might be helpful.

Subcategories

This category will hold articles regarding developement in Excel VBA. It will serve as a wiki and an Excel VBA Framework for myself.

Some development tasks reoccur for every customer. Since I am a lazy bum it will be nice to have a central source where I can reuse source code from.

This category holds articles regarding general things in MS Office VBA independent from the MS Office application.  

This category holds articles regarding Access VBA, but also general things I come accross Access and its usage in companies.