Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
551 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers 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
Search our website
We also send out useful tips in a monthly email newsletter ...
Although you're probably itching to jump straight in and start writing code there are a few things you'll need to do first! This section shows you how to get started in the Visual Basic Editor application.
Get used to this view: you'll be spending a lot of time here!
You don't need any files for this page.
There is no example code to download for this section.
Start by opening Excel and creating a blank workbook. All VBA code must be stored in some form of Microsoft Office document - as this is an Excel VBA course it makes sense to use an Excel workbook!
Now we need to open the Visual Basic Editor (VBE) - the application in which you'll write all your VBA code. One way to do this is to use the Developer tab in the Excel ribbon. If you can't see the Developer tab, you can customise the ribbon to display it:
Right-click the name of any visible ribbon tab and choose Customize the Ribbon...
You can now choose to display the Developer tab:
Check the box next to Developer and then click OK.
You can now open the VBE by choosing Developer | Visual Basic from the Excel ribbon:
Click the first tool on the Developer tab.
You can also press Alt + F11 on the keyboard to open the VBE. It's still worth displaying the Developer tab as it contains several other useful tools.
When you first open the VBE it should look something like the image below:
The default appearance of the VBE.
When you want to return to Excel, you can do so using one of several methods:
Menu | Keyboard | Toolbar |
---|---|---|
View | Microsoft Excel | Alt + F11 |
The VBE displays two windows by default:
Window name | Description |
---|---|
Project Explorer | Shows a list of all the open VBA projects and the objects which belong to them. This appears in the top left area of the VBE. |
Properties Window | Shows the attributes of the object that is selected in the Project Explorer. This appears in the bottom left area of the VBE. |
If you can't see these two windows you can use the View menu at the top of the VBE to display them:
Use the View menu to display any windows in the VBE.
Before you can write any VBA code, you'll need to create a container in which to put it. The basic container for code in VBA is called a module and you can create one as shown in the diagram below:
Right-click inside the Project Explorer (here we've right-clicked on the project name) and choose Insert | Module to create a new module.
You can also choose Insert | Module from the VBE menu to create a new module.
When you've inserted a module your screen should resemble the one shown below:
The module appears in the Project Explorer and opens in a separate window in the main area of the screen.
You can manipulate the module window using the standard controls in the top right corner of its window:
You can minimise, maximise and close the module window using the three buttons in its top right corner.
If you close a module, you can double-click its name in the Project Explorer to reopen it.
As you begin to work on larger and more complex projects, you'll find it useful to use multiple modules to organise your code. You can insert as many modules into a project as you like:
You can insert a new module into the project in the same way as you inserted the first.
You can view the code in a module by double-clicking its name in the Project Explorer window:
Double-click a module to see the code it contains. The name at the top of the VBE window indicates which module you are currently viewing.
You can delete a module from a project by right-clicking its name and choosing to remove it:
Right-click the module in the Project Explorer window and choose the Remove option from the menu.
You'll be asked if you want to export the module before it is removed from the project:
Click No to delete the module without exporting it.
One last thing you may wish to do before you start writing code is to change the default font size of the VBE. To do this, choose Tools | Options... from the VBE menu and complete the dialog box as shown below:
Select the Editor Format tab at the top of the dialog box and select a new font size from the drop down list shown. Click OK to confirm your choice.
Congratulations, you're now ready to start writing VBA code! Start the next part of this lesson to learn how.
You don't have much to practise yet! It's probably best to move to the next part of this lesson to learn how to write basic VBA code.
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.