Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ExtendOffice (https://www.extendoffice.com)
Office Tips & Tricks Tips & Tricks for Excel Tips & Tricks for Word Tips & Tricks for Outlook
(/documents.html) (/documents/excel.html) (/documents/word.html) (/documents/outlook.html)
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.
Combine multiple worksheets or workbooks into one single worksheet or workbook may be a huge task in your daily work. But, if
you have Kutools for Excel, its powerful utility – Combine can help you quickly combine multiple worksheets, workbooks into one
worksheet or workbook.
Kutools for Excel includes more than 120 handy Excel tools. Free to try with no limitation in 60 days. Download the free trial
now (https://d2d42mpnbqmzj3.cloudfront.net/downloads/KutoolsforExcelSetup.exe)
https://www.extendoffice.com/documents/excel/4354-excel-click-on-cell-to-run-macro.html#a1 1/8
3/27/2018 How to trigger or run a Macro by clicking a specific cell in Excel?
(https://d2d42mpnbqmzj3.cloudfront.net/downloads/KutoolsforExcelSetup.exe)
Office Tab: Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.
(/product/office-tab.html) Try now (https://d2d42mpnbqmzj3.cloudfront.net/downloads/SetupOfficeTab.exe)
https://www.extendoffice.com/documents/excel/4354-excel-click-on-cell-to-run-macro.html#a1 2/8
3/27/2018
Kutools for Excel: 200 new features for Excel,How to trigger or run a Macro by clicking a specific cell in Excel?
make Excel much easy and powerful, increase productivity
immediately. (/product/kutools-for-excel.html)
Try now (https://d2d42mpnbqmzj3.cloudfront.net/downloads/KutoolsforExcelSetup.exe)
(/product/office-tab.html)
Amazing! Using Tabs In Excel Like Firefox, Chrome, Internet Explore 10! (/Product/O
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.
1 Option Explicit
2
3 Private Sub Worksheet_SelectionChange(ByVal Target As Range)
4 If Selection.Count = 1 Then
5 If Not Intersect(Target, Range("D4")) Is Nothing Then
6 Call MyMacro
7 End If
8 End If
9 End Sub
https://www.extendoffice.com/documents/excel/4354-excel-click-on-cell-to-run-macro.html#a1 3/8
3/27/2018 How to trigger or run a Macro by clicking a specific cell in Excel?
Notes:
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.
Related Articles:
Bring handy tabs to Excel and other Office software, just like Chrome, Firefox and new Internet Explorer.
Amazing! Increase your productivity in 5 minutes. Don't need any special skills, save two hours every day!
200 New Features for Excel, Make Excel Much Easy and Powerful:
Merge Cell/Rows/Columns without Losing Data.
Combine and Consolidate Multiple Sheets and Workbooks.
Compare Ranges, Copy Multiple Ranges, Convert Text to Date, Unit and Currency Conversion.
Count by Colors, Paging Subtotals, Advanced Sort and Super Filter,
More Select/Insert/Delete/Text/Format/Link/Comment/Workbooks/Worksheets Tools...
https://www.extendoffice.com/documents/excel/4354-excel-click-on-cell-to-run-macro.html#a1 5/8
3/27/2018 How to trigger or run a Macro by clicking a specific cell in Excel?
(/product/kutools-for-excel.html)
https://www.extendoffice.com/documents/excel/4354-excel-click-on-cell-to-run-macro.html#a1 6/8
3/27/2018 How to trigger or run a Macro by clicking a specific cell in Excel?
(/product/kutools-for-excel.html) (/download/kutools-for-
excel.html) (/order/kutools-for-excel.html)
Sort by Newest b
Say something here...
PEOPLE IN CONVERSATION:
This worked perfectly and will save me a load of time - thank you for sharing your knowledge - much appreciated!
Reply Share
If you want to have multiple macros, cells running different macros on the same page - is that possible?
Reply Share
Dear Simon,
The below VBA script can help you to run different macros by clicking on cells on the same page.
Trigger Or Run A Macro By Clicking A Specific Cell With VBA Code, couldn't get this to work. I tried it many different way, but it never
acheived what was promised.
Reply Share
This code will only work if you place it in the "ThisWorkbook" module. It does not work on a general module.
workbookname > Microsft Excel Objects > ThisWorkbook.
Reply Share
This code will work on worksheet code module. You need to right click on sheet tab and click on 'View Code'. This will open
code module for that worksheet only. Then paste the mentioned code.
Reply Share
Home (/) Knowledge (/documents.html) Support (/support.html) Forum (/forum.html) Privacy Policy (/privacy-policy.html)
About Us (/support/about-us.html)
Copyright © 2009 - 2018 ExtendOffice.com | All Rights Reserved. Sitemap (/component/jmap/sitemap.html)
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other
countries.
https://www.extendoffice.com/documents/excel/4354-excel-click-on-cell-to-run-macro.html#a1 8/8