How to trigger or run a Macro by clicking a specific cell in Excel?
While working with Microsoft Excel, you may know how to run a certain Macro with a Command Button. But do you know how to run a Macro by just clicking on a specific cell in a worksheet? This article will show you method of triggering a Macro by clicking on a specific cell in details.
Trigger or run a Macro by clicking a specific cell with VBA code
Trigger or run a Macro by clicking a specific cell with VBA code
The following VBA code can help you to run a Macro by clicking a specific cell in Excel. Please do as follows.
1. On the worksheet with the cell you need to click to run a Macro, right click the sheet tab, and then click View Code from the context menu.
2. In the Microsoft Visual Basic for Applications window, copy and paste the below VBA script into the Code window.
VBA code: Trigger or run a Macro by clicking a specific cell
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Count = 1 Then
If Not Intersect(Target, Range("D4")) Is Nothing Then
Call MyMacro
End If
End If
End Sub
Notes:
1. In the code, D4 is the cell you will click to run Macro;
2. Please replace the code name MyMacro with the Macro you will run in the worksheet. See screenshot:
3. Press the Alt + Q keys simultaneously to close the Microsoft Visual Basic for Applications window.
From now on, when clicking on cell D4 in current worksheet, your specified Macro will be triggered immediately.

Unlock Excel Magic with Kutools AI
- Smart Execution: Perform cell operations, analyze data, and create charts—all driven by simple commands.
- Custom Formulas: Generate tailored formulas to streamline your workflows.
- VBA Coding: Write and implement VBA code effortlessly.
- Formula Interpretation: Understand complex formulas with ease.
- Text Translation: Break language barriers within your spreadsheets.
Related articles:
- How to pop up a calendar when clicking a specific cell in Excel?
- How to change cell color when cell is clicked or selected in Excel?
- How to pop up message box when clicking on a certain cell in Excel?
- How to disable button after clicking once in Excel?
- How to disable right click on sheet tab in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!