Phone (01457) 858877 or email
Use this free online training in Excel Visual Basic for Applications (VBA) to learn how to program macros within Excel. The tutorial covers everything from basic recording through to creating classes - something for everyone!
This free tutorial provides an on-line training course in how to write Visual Basic for Applications macros within Excel. (Note that we also run classroom-based training courses in VBA and also in Excel in London and other UK cities).
A good place to start when learning VBA for Excel is to learn how to record macros, and then start writing basic code yourself:
| Tutorial | Learn how to ... |
|---|---|
| Recording macros in Excel VBA | Record macros in Excel (and also various techniques for playing them back and for modifying the code generated by Excel). |
| Writing Visual Basic macros in Excel | Start writing VBA code within Excel to automate your workbooks |
| Commenting code | The art and science of writing comments for your VBA code. |
| Short-cut keys | How to assign a short-cut key to run any macro. |
You can't do much in Excel VBA without knowing how to move around a worksheet!
| Tutorial | Learn how to ... |
|---|---|
| Selecting cells - absolute | Go to a cell or range in Excel. |
| Selecting cells - relative | Select cells and ranges relative to your starting position. |
The next thing to learn is how to display input and message boxes (as part of this module you'll also learn about variables):
| Tutorial | Learn how to ... |
|---|---|
| Variables | Use variables and constants in your code |
| Message boxes | Use the MsgBox command to display pop-up messages. |
| Input boxes | Use the InputBox function to get data from your user. |
The next thing to understand is how VBA is written, using objects, collections, properties and methods:
| Tutorial | What it's about |
|---|---|
| The Excel Object Model | VBA is what's called an object-orientated programming language - learn what this means! |
Any programming language allows you to test conditions and do things iteratively (in loops), and Visual Basic for Applications is no different:
| Tutorial | Learn how to ... |
|---|---|
| Testing conditions | Use IF statements and SELECT ... CASE to test conditions. |
| Looping | Learn the four main types of loop built into VBA. |
In Excel VBA you can attach code to events which happen for a workbook or worksheet (such as running code whenever you open a particular file):
| Tutorial | Learn how to ... |
|---|---|
| Event-handling macros | Attach code to events for Excel workbooks and worksheets. |
| Event sinks | Create event sinks to capture application-level events (such as a user creating a new workbook). |
Sometimes your programs will have bugs in (!) - these tutorials show how to minimise the chances of these occurring, and track them down when they do:
| Tutorial | Learn how to ... |
|---|---|
| Debugging in VBA | Stepping through code, setting breakpoints, using the call stack and other options for debugging macros. |
| Error-handling | Using the Err object to display errors, and trapping for errors using ON ERROR and RESUME. |
You can link to other applications such as Word or PowerPoint from within Excel,:
| Tutorial | Learn how to ... |
|---|---|
| Linking to Word, etc | Write code using references to manipulate documents in Word, presentations in PowerPoint, etc. |
| CreateObject and GetObject | An alternative way to create and use references (of interest mostly just for techies!). |
| Talking to Internet Explorer | You can get VBA programs to fill in forms in Internet Explorer, if you reference the right object library. |
| Programming references | How to write code to create references programmatically (not for the faint-hearted). |
You can use FileDialogs to choose files to open or save, TextStream objects to read and write files and create a FileSystemObject to copy, move or delete files:
| Tutorial | Learn how to ... |
|---|---|
| FileDialogs | Use FileDialogs to make it easier for users to choose files. |
| Reading and writing files | Read from a file line-by-line (or write to one) using a TextStream. |
| Manipulating files and folders | Create a reference to the Microsoft Scripting Runtime object library to get access to all of the files on your hard disk! |
How to use ActiveX Data Objects (ADO) to link to SQL Server or Access databases from within Excel (or do it the other way round, and link from Access to Excel, say):
| Tutorial | Learn how to ... |
|---|---|
| Working with records | List records, add records or edit or delete records in a table in Access, SQL Server, etc. |
When you're familiar with basic programming, it's time to learn advanced concepts, such as passing arguments and using recursion:
| Tutorial | Learn how to ... |
|---|---|
| Passing arguments | Pass arguments to subroutines (using ByRef and ByVal) and understand optional arguments and ParamArray. |
| Recursion | What recursive programming is, and how to use it to list files or to list out hierarchical data structures. |
In addition to the built-in Excel functions, you can write your own, and you can also incorporate functions within your code to make it easier to write and read:
| Tutorial | Learn how to ... |
|---|---|
| Creating functions | Write your own functions, and then call them from within your code or incorporate them into Excel. |
| Sharing functions using add-ins | Create add-ins to share code that you've written between different workbooks. |
Variables aren't the only way to hold data in VBA programs!
| Tutorial | Learn how to ... |
|---|---|
| Arrays | Learn how to create static and dynamic arrays, and how to use multi-dimensional arrays. |
| Enumerations | Learn how to write strongly-typed code with enumerations (and indeed what strongly-typed coding means!). |
Create your own dialog boxes, by drawing user forms on screen and integrating them with your macros:
| Tutorial | Learn how to ... |
|---|---|
| Drawing user forms | Use the toolbox and properties window to draw user forms on screen. |
| User forms and macros | Integrate macros and user forms (including validating data entered using code). |
| Advanced controls | Learn how to create advanced controls such as combo boxes, list boxes, option buttons, MultiPages and SpinButtons. |
Classes within Excel VBA are your own customised objects, to which you breathe life by writing methods and properties:
| Tutorial | What it covers |
|---|---|
| Creating classes | An explanation of what classes are, and how to create and use class modules in VBA. |
| Collections | Creating your own collections within Visual Basic (both typed and untyped). |
Learn how to distinguish between macros you trust and macros you don't: digital certificates, trust centres and more!
| Tutorial | What it covers |
|---|---|
| Macro security | How macro security and digital certificates work in Excel VBA. |
| Deleting certificates | How to delete digital certificates from your computer. |
One final thought - Wise Owl also run classroom-based Excel and VBA training courses in the UK (and overseas, if you're willing to pay expenses!).
Comments on this blog
This blog has 4 comments: