PHAS1240 Computing

UCL logo
VBA

The introduction to the use of a programming language (Visual Basic for Applications) will also be covered in part in the lectures, but mostly directly at the computer terminal.  As with the Excel section there are files (in WORD or PDF format) defining the tasks.

The lectures and practical exercises on Visual Basic for Applications (VBA) are used only as an introduction to the topic of programming. They do not aim to exhaustively teach VBA specifically or programming in general.  VBA in Excel is used as a vehicle to introduce programming as its used in many Windows applications (so readily available) and you can easily couple your code to data, calculations or plots in a spreadsheet.

Because of VBA's close connection with Excel, one way to begin to study programming is to let Excel record a macro - a record of your spreadsheet actions.  This is the first VBA exercise, VBA-1.  You can also begin to learn programming by examining an existing program to see if you can understand what it does.  Thus in the VBA exercises, VBA-2 you first  record and then annotate a macro performing a known sequence of operations.  You then try to annotate an existing macro to see if you can identify what it does. 

    There are several Excel/VBA exercises that require writing code to compute simple mathematical functions. The first of these VBA-3 involves the simple formulae for scalar and vector products of vectors.  You then use your procedures (functions)  as building blocks to solve a more complex problem.  The exercises VBA-4 and VBA-5 involve mathematical series and numerical integration respectively. 

There are some notes on the topics of

to introduce formally the syntax of the VBA language.   The last topic listed above is probably too advanced for this course, but is included for those who may wish to know a little more about the ideas behind the language. 

Some parts of these notes will be discussed in lectures.