Run or execute a macro code when sheet is selected from a workbook with VBA code
The following simple code can help you to trigger a macro code when activating a specific sheet, please do as this:
1. Right click the sheet tab that you want to execute the macro when activating it, and then choose View Code from the context menu, and in the opened Microsoft Visual Basic for applications window, copy and paste the following code into the blank Module:
VBA code: Run a macro code when activating a sheet from a workbook:
Private Sub Worksheet_Activate()
Note: In the above code, please change the macro name to your own.
2. Then save and close the code window, now, when you clicking or activating this specific sheet tab, this macro will be triggered immediately.
Select Duplicate or Unique Rows; Select Blank Rows (all cells are empty); Super Find and Fuzzy Find in Many Workbooks; Random Select...
Exact Copy Multiple Cells without changing formula reference; Auto Create References to Multiple Sheets; Insert Bullets, Check Boxes and more...
Extract Text, Add Text, Remove by Position, Remove Space; Create and Print Paging Subtotals; Convert Between Cells Content and Comments...
Super Filter (save and apply filter schemes to other sheets); Advanced Sort by month/week/day, frequency and more; Special Filter by bold, italic...
Combine Workbooks and WorkSheets; Merge Tables based on key columns; Split Data into Multiple Sheets; Batch Convert xls, xlsx and PDF...
More than 300 powerful features. Supports Office/Excel
2007-2019 and 365. Supports all languages. Easy deploying in your enterprise or organization. Full features
30-day free trial. 60-day money back guarantee.