Observations on Visual BASIC for Applications

So I find myself doing development in Visual BASIC for Applications again. It’s central to all Microsoft Office applications. In essence it lets one perform conditional logic. Some of that functionality is already present in applications like Excel. As an example you can do IF tests, Data Lookups, etc. But it’s severely limited.

So I’m designing a spreadsheet with a dropdown box. In Excel 2007 if you just use the standard dropdown it won’t let you reference it in VBA.

Instead you have to use an Active-X dropdown box. Great.

Now I’ve always been able to basically say ‘a = dropbox1.value’ to get the selected value. But as I said, using the standard Excel dropdown resulted in the object not being accessible. Great.

But Active-X acts just like the old style. All I had to do is snag:

listItems = ListBox1.Value

And then do my case on istItems. Since I had configured the ListBox to be single selection and since there’s only one data field in it I didn’t have to sweep through it. Much easier.


2 thoughts on “Observations on Visual BASIC for Applications

  1. I learned VBA 13 years ago, and soon felt like it was a prison. It sounds like your project could be done in JavaScript — if only Microsoft supported it.

    1. Nah – and they even have an elif construct in there now! Woot!

      Lets see, I learned VBA back in 1997 so that makes it 16 years for me. I’ve used it in Access, Excel, Word and Outlook of all things.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.