563 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owls only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
In earlier parts of the lesson we relied on using on-screen hints to provide us with help. While these tooltips can be useful, there's only so much information that can be squeezed into them. This part of the lesson explains how you can access detailed help on the various objects, methods and properties that you use.
The tooltips are useful, but don't provide much in the way of detailed information.
You don't need any files for this page.
You can click here to download a file containing the sample code.
To get started, create a new workbook and open the VBE. Insert a new module and create a subroutine as shown below:
You can use a different name for the subroutine if you like.
Let's say that we wanted to work out how to use the BorderAround method to draw a border around the currently selected cell. Start by writing the instruction which applies the BorderAround method to the ActiveCell object:
The tooltip shows us the names of the parameters, but not the values that we are allowed to pass to them.
To get more help on how to use the BorderAround method we can use VBA's built-in dictionary, the Object Browser.
You can open in the Object Browser in a couple of different ways, as shown below:
You can choose View | Object Browser from the menu, or press F2 to open the Object Browser.
The Object Browser opens in the main code window of the VBE (and may obscure your code in the process):
To return to your code you can close the Object Browser by clicking the cross in the top right corner.
The Object Browser shows two lists of items. On the left is a list of classes. A class is a definition of a type of object, such as a worksheet or a range. When you select a class from the list on the left, the list on the right shows the members of the selected class. Members are the methods and properties (as well as other associated items) of the selected class.
One way to get help with the Object Browser is to follow the sequence of keywords you've written in your code. We began our instruction by referring to the ActiveCell:
ActiveCell is a property in the special class called Global. You can click on ActiveCell in the list on the right to show this information at the bottom of the Object Browser.
As you saw in an earlier part of this lesson, you normally apply a method or property by first referring to an object. The usual syntax is shown below:
'apply a method to an object
'change a property of an object
Object.Property = something
If a method or property belongs to the Global class, you can place the method or property at the beginning of an instruction. The global method or property returns a reference to an object to which you can apply further methods and properties.
To continue finding help, we need to know what class of object the ActiveCell property returns. When you click on ActiveCell, you can see this information at the bottom of the Object Browser:
The hint at the bottom of the window shows that the ActiveCell property returns a Range object. You can click the Range keyword to see further help.
Clicking the Range keyword at the bottom of the Object Browser automatically selects the Range class in the list on the left:
You could also scroll down the list of classes and select Range manually. When you do this, the list on the right shows the methods and properties of the Range class.
Finally, you can scroll through the list on the right to find the BorderAround method:
Clicking the BorderAround method in the list shows its parameter list in the bottom part of the Object Browser.
Now that you've found the method for which you want to get help, you can do so by right-clicking its name in the Object Browser:
From the menu, select Help to open the online help system.
Choosing Help in the menu shown above will automatically open your default web browser and navigate to a page which displays help on the selected keyword:
The online help page provides a full description of the keyword you have selected.
As well as providing a detailed explanation of the keyword, the help page also provides links to further help. In the example above we can click the XlLineStyle link to find out more information on the available options for the LineStyle parameter:
The next page describes the options we can use to pass an argument to the LineStyle parameter.
You can click the Back button of your browser to return to the main help page of the BorderAround method. You can scroll down the page to find more useful information on how the method works:
The Remarks section describes things to be careful of when using the method, such as parameters which can't be used together.
When you have the information you need, you can close the web browser and return to your code to complete the instruction you are writing:
We can now be more confident that the code we've written is correct!
If you want to avoid using the Object Browser, in many cases you can jump directly to the online help system from the code window. To do this, you need to type the keyword for which you want to get help into the code window:
Enter the code you need to find help on. While the text cursor is in contact with the keyword on which you want to get help, press F1 on the keyboard.
Pressing F1 will open the web browser and navigate to the help page which corresponds to the keyword that the text cursor is in contact with:
The layout of this help page is the same as that in the previous example.
Once you've gathered the information you need, you can close the browser and return to your code.
This context-sensitive technique of opening the online help system isn't totally reliable! Sometimes you'll need to revert to using the Object Browser to get to the information you need.
The best way to practise using the Object Browser and online help system is to use it as frequently as possible. As you progress through the rest of this training course, try using the help system to discover more information about the VBA keywords that you encounter.
25 Aytoun Street