G
Guest
Is it possible to click in a cell in Excel to run a macro? assign macro to
cell type thing.
cell type thing.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Gord Dibben said:You could use doubleclick event code.
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
'Substitute your cells/macro names.
Select Case Target.Address(False, False)
Case "A1"
Cancel = True
MyA1Macro
Case "J10"
Cancel = True
MyJ10Macro
Case "AB275"
Cancel = True
MyAB275Macro
End Select
End Sub
This is sheet event code. Right-click on the sheet tab and "View Code"
Copy/paste the above into that sheet module.
Gord Dibben MS Excel MVP
JE McGimpsey said:You can use the Worksheet_SelectionChange() event (put this in the
worksheet code module: right-click the worksheet tab and choose View
Code).
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If ActiveCell.Address(False, False) = "A1" Then MyMacro
End Sub
But this will also be run when you tab/arrow into the cell. You might
want to use the double-click event instead:
Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
If Target.Address(False, False) = "J10" Then
MyMacro
Cancel = True
End If
End Sub
1 are merged to accommodate a title, use Center Across Selection instead.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.