Can I launch macro by a cell click ?

C

Cedric Dennis

Hi
Can I launch a macro simply by clicking a cell ?
What command would I need to type in the cell ?
Please help if you can.
Thankyou
Cedric
 
R

Ron de Bruin

You can use this event in the sheet module for Cell A1
It will also run if you select the cell with the arrow keys

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("A1"), Target) Is Nothing Then
yourmacro
End If
End Sub

Sub yourmacro()
MsgBox "Hi"
End Sub
 
D

Don Guillett

right click sheet tab>view code>insert this>save to suit>SAVE

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$C$1" Then doit
End Sub
Sub doit()
MsgBox "Hi"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top