Archive of Mr Excel Message Board

Back to Excel VBA archive index
Back to archive home

How to run a Macro when cell is clicked on
Posted by Ed on January 03, 2001 11:45 AM
I thought I saw this code in this site but I can not locate it. I need to run a macro when the user clicks on a cell. Any thoughts??

| Check out our Excel VBA Resources
|
 |
 |
 |
 |
 |
Re: How to run a Macro when cell is clicked on
Posted by Dave on January 04, 2001 12:22 AM
Hi Ed
Right click on the sheet name tab and select "View Code" and paste in this code:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$A$1" Then MsgBox "I'm A1"
End Sub
Dave
OzGrid Business Applications

This archive is from the original message board at www.MrExcel.com.
All contents © 1998-2004 MrExcel.com.
Visit our
online store to buy searchable CD's with thousands of VBA and Excel answers.
Microsoft Excel is a registered trademark of the Microsoft Corporation.
MrExcel is a registered trademark of Tickling Keys, Inc.