View Full Version : Run a Macro by selecting a cell
jimmyyy
12-02-2006, 02:31 PM
Is it possible to run a macro by selecting a cello in a worksheet?
I read one post online saying its not possible:think:
Bob Phillips
12-02-2006, 02:36 PM
Of course you can.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "A1" '<== change to suit
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
'your code
End With
End If
End Sub
This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click
jimmyyy
12-02-2006, 02:41 PM
i Found this but dont compleatly understand it:
To have code run automatically when a specfic cell in a specific cell is selected then use
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
A simple example is :
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
MsgBox Target.Address
End Sub
jimmyyy
12-02-2006, 02:43 PM
Awsome, ill try it out thanks Xld
jimmyyy
12-02-2006, 02:48 PM
works like a charm
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.