Enhanced VBA IntelliSense

IntelliSense is a collection of code editing assistance features that help developers write code faster and with fewer errors. Here we show the use of VBA IntelliSense extensions provided by Code VBA roughly in order that you will encounter them while coding and from simple to more involved.

Adding a new procedure

Sub menu

When you start writing a procedure typing the s for Sub or f (Function) or pro (property) immediately triggers a corresponding menu. Selecting the first item inserts the common block with the cursor just before () to allow typing the procedure name.


Sub |()

End Sub

The first time you will be startled by this behaviour and even feel annoyed by the interuption. On the upside, you may notice the menu provides some features worth investigating.

Declaring variables

Dim variable declaration completion menu

excel dim menu

Typing dim (a keyword trigger) opens the variable declaration completion menu. Selecting the type you need inserts the boilerplate declaration.

Dim wb| As Workbook

Supply a suitable name after the prefix to complete the declaration.

Auto Declare completion

Actually, with the Auto Declare feature you don't have to declare variables yourself anymore. For example, if you type

strName=

... in addition to the assignment menu appearing (see next section) the declaration has been added:


Dim strName As String
strName=

Variable assignment suggestions

variable assignment name

In case of a variable assignment like above a menu with suggestions for the right side appears. Which depends on the type of the variable. In the example of String strName this has many options, just to name a few:

  • An empty string literal "" for you to fill
  • A New variable, function or constant to be automatically declared
  • A variable already known in the procedure, possibly of type String but Visual Basic also allows other type sources.
  • A Name present somewhere in your project, or a folder or filename to select using a dialog.
  • A VBA function call such as Trim(...)
  • A property value from an Object (ActiveCell.Value), etcetera
variable assignment date

Example

If we are assigning a value to Date variable the menu would looks like the screenshot on the right. You can select and insert code for

  • Three literals representing date and or time: #2/12/2026 7:58:06 AM# .
  • Use the Date function which gives the date of today, or Now for date and time.
  • Use the DateAdd function to calculate a date/time in the future.
  • Select a code snippet to calculate a date in the future, e.g. First day in month: dt = DateSerial(Year(dt), Month(dt), 1). A long list of such date functions is available, they are located in the VBA Code Libary.

Object variable assignment suggestions

object variable assignment range

The included Object variable assignment support uses deep knowledge of the relevant Office application objects to suggest how to set an object of given type.

  • Ranges always refer to a sheet. Here we selected Sheet1, but the code might also start from a New Sheet variable
  • Code that will be inserted when clicking an item is visible in a toolltip.
  • In the current example the menu has ... which indicates that clicking it will open a dialog. In this case a Procedure Call Builder dialog that lets you give the details of the Range methods.
  • The keyword Set is automatically added to make the Object variable assignment syntactically correct.

Dim rng As Range
Set rng = Sheet1.Range(Cell1:="A4", Cell2:="D10")

Set statement completion

The above is further extended in that, with trigger keyword Set, it knows the object variables in the current procedure and can write complete statements combining knowledge of which objects are available with their methods that can be used to Set a related object.

set statement completion
Set statement completion is used here to specify the subscriptions range to be in the Account worksheet.

If New String Variable is selected in the Range submenu, the below code is created - using the default variable name in the dialog.


Dim strRange As String: strRange =
Set rngSubscriptions = wsAccount.Range(Cell1:=strRange)

Next, you can easily assign the missing name by placing the cursor after strRange = and activating the assignment statement suggestions completions.

select range
Use completions menu range

Dim strRange As String: strRange = "[Account4223.xlsm]Sheet1!B4:C6"

Argument completion suggestion

When calling a procedure you often have to supply arguments for the procedure parameters. Argument completion very convenient for this. It works for all procedures in your project, custom or built-in, object methods or module procedures.

  • Arguments not yet supplied can be selected by name.
  • Tooltip quick info describes what the parameter is for.
  • Select as argument the variable you need to use or create a new one, a property of an object or even a VBA procedure or snippet.
procedure argument completion

If Then Else statement block with condition

When you type If the below menu opens. The screenshot below shows the creation of an If Then Else statement block. Notice that:

  • The If Then Else menu is the third option out of the main four in the If menu.
  • To only get the bare structure, select the empty line in the second list.
  • The rest of the second list allows construction of the condition part.
  • Using access key B opend the VBA submenu which contains functions and snippets that can be used as Boolean condition parts.
  • Top right shows the hover Quick Info tooltip with the code that will be inserted if the menu item is clicked, a description of the last selected procedure (here the IsDate function) and F1 to indicate the presence of online help.
If Then Else statement block with condition

The resulting code as already presented in the Tooltip:


If IsDate(str) Then

Else

End If