Using the Condition Builder

One of the things you do most while programming is specifying conditions: If [condition] Then, Do While [condition], booContinue = [condition], and so on. In many cases these conditions are very simple so you just type them in. However, if conditions are more complex and concern multiple variables, the builder will come in handy. The recording below shows for a fictituous nonsensical condition expression how the different parts of the tool would have helped you.

Condition Builder

Building blocks for conditions

Top right shows the buttons that give access to different elements you may want to use in your expression. Note that at the bottom there are the usual boolean and comparison operators. You can use them to insert selected elements together with the operators in one go.


Here you can pick already present Boolean variables e.g. booIsPresented, or common expressions that return booleans, e.g. IsObject(ws).


Fills the lists with String type variables and also object variables and associated string properties. Use the operators to insert the selected elements from the first and optionally the second list in one go. Double-clicking an item in the list is another fast way to insert the variable or property.


Fills the lists with numeric type variables (Integer, Double, etcetera) and also object variables and associated numeric properties.

Enumerated type values

Enumerated types specify a list of values that can be selected from. Office VBA has hundreds such types ready built-in:

  • VbMsgBoxResult: vbOk, vbCancel, ...
  • VbDayOfWeek: vbMonday, vbTuesday, ..., vbUseSystemDayOfWeek
  • XlRowCol: xlRows, xlColumns
  • XlSheetType: xlWorksheet, xlChart, ...

Obviously, if enums represent the allowed values of so many properties, you will often let your code make decisions on these enums, e.g. if in your code you specified the variable ret As VbMsgBoxResult then, after calling the MsgBox function you will check the result: If ret = vbOk Then.

Defining Enums is good practice you should adopt yourself - the Code VBA add-in has a small tool to help you define them. The Condition Builder also is aware of such. custom Enumerated types variables, they will appear if you pressed the Enum button.