
#Winwedge and excel vba tutorial code
In the above section, I covered the different types of events.īased on the type of event, you need to put the code in the relevant object.įor example, if it’s a worksheet related event, it should go in the code window of the worksheet object. ‘OnKey’ event allows you to execute a code when a specific keystroke (or a combination of keystrokes) is used. ‘OnTime’ event allows you to execute a code at a specific time or after a specific time has elapsed. OnTime and OnKey Events: These are two events that don’t fit in any of the above categories.
#Winwedge and excel vba tutorial series
Examples of such events would include changing the series of the chart or resizing the chart. A chart sheets purpose is to hold a chart. A chart sheet is different than a worksheet (which is where most of us are used to work in Excel).

Similarly, you can create VBA codes for many such events (as we will see later in this article).īelow is a short visual that shows the double-click event in action. You can use the double-click event for this. Now, whenever anyone inserts a new worksheet, this code would automatically be executed and add the year prefix to the worksheet’s name.Īnother example could be that you want to change the color of the cell when someone double-clicks on it. So you only need to write the code and place it in the correct event subroutine (this is covered later in this article).įor example, if you insert a new worksheet and you want it to have a year prefix, you can write the code for it. This means that as soon as an event occurs, and if you have specified a code for that event, that code would instantly be executed.Įxcel automatically does this as soon as it notices that an event has taken place. There are many such events in VBA, and you can create codes for these events.

When you double-click on a cell, it’s an event.

When you insert a new worksheet, it’s an event. Let me first explain what is an event in VBA.Īn event is an action that can trigger the execution of the specified macro.įor example, when you open a new workbook, it’s an event. Worksheet Level Events (Explained with Examples).Workbook Level Events (Explained with Examples).

