![]() ![]() Similarly, the Worksheet_Deactivate event occurs when you leave the current worksheet and activate a different worksheet. ![]() We already learn Excel detects when a worksheet is activated and fires the Worksheet_Activate event. ![]() You also can hide the menu item rather than disable it, simply set the Visible property to False: Private Sub Worksheet_Activate()ĬommandBars("Cell").Controls("Cut").Visible = FalseĮnd Sub Worksheet_Deactivate Event Procedure In the following example, we’ll disable a shortcut menu item “ Cut” (which was added to the Cells menu) when the Sheet1 is activated: Private Sub Worksheet_Activate()ĬommandBars("Cell").Controls("Cut").Enabled = False For example, when you right-click on a ribbon, a different menu appears, but when you right-click on a cell, a completely different menu appears. This menu varies at different Excel parts. The second example demonstrates how to automatically refresh all pivot tables whenever the particular worksheet is activated: Private Sub Worksheet_Activate()įor i = 1 To ĪctiveSheet.PivotTables(i).PivotCache.RefreshĮxcel shows you a shortcut menu when you right-click. This code simply pops up a message box that displays Welcome Back message: Private Sub Worksheet_Activate() Following is a very simple example that is executed whenever a particular worksheet is activated. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |