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).Understanding the Role of Arguments in VBA Events.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |