Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

run excel macro on cell select or event to do same 1

Status
Not open for further replies.

DavidAWH

Programmer
Nov 4, 2001
16
0
0
AU
Hi
Does any one know if it is possible to run an excel macro when a user clicks a certain cell or is there an event ( maybe sheet1_click(row,column) )
thanks in advanced
DavidAWH
 
Yep, sure is.

Go to the worksheet module in VBA (for whatever sheet you're interested in creating code for). Use the drop down menus to get the Selection_Change event of the worksheet.

Code:
Option Explicit
Dim cll_rng As Range
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Set cll_rng = Range("a1", Range("d9"))
If Not Intersect(cll_rng, Target) Is Nothing Then
     ' code to execute
     End If
Set cll_rng = Nothing
End Sub

Here I've used a rectangular range of a1 to d9 as containing the cells which activate the code, but change to your requirements (obviously!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top