VBA Worksheet Events



The object of this lesson is to become more familiar at using Worksheet Events.
For example, to create a new desk we right click the mouse in a cell within a predefined area of the worksheet. However, right clicking on a desk that already exists would delete the desk. If we double right click the mouse on a desk then we will assign to that desk an ordered number. Left clicking on the "Teacher's Desk" will randomly select a numbered desk and alter its colour to be a darker shade that matches the overall chosen desk colour.

All of these mouse operations are types of Worksheet Events and we can code something to happen when the event takes place.

Shown below are two examples of the final Excel file of class layouts, partially filled with students in which a student has been selected at random - say to answer a question...

.

Lesson Text
Notice that at the end of this file is an appendix from which the VBA code may be highlighted, copied and pasted into the Visual Basic Editor (VBE) to save yourself some time.

Excel Files (1), (2a), (2b), (3), (4), (5), (6)

My advice is for you to download the files directly to your hard drive by right-clicking on the link and then selecting "Save Target As..." - otherwise the Excel files may not work fully in your browser window!