Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Run macro when cell is highlighted.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Defoes Right Boot - 24 Jan 2006 11:46 GMT
I have a worksheet which displays a list of items in column N based on the
user input in cell C5.

What I want to do is allow the user to click on any of the cells in column N
(without the possibility of accidentally editing them) which will then run a
macro based on the value in the specific cell they clicked on.

Is this possible? And if so, how do I go about it?

Many thanks

Phil
Norman Jones - 24 Jan 2006 12:01 GMT
Hi Right Boot,

Try:
'=============>>
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

   If Target.Cells.Count > 1 Then Exit Sub

   If Not Intersect(Target, Columns("N")) Is Nothing Then
       Select Case Target.Value
       Case 1: Call MacroA
       Case 2: Call MacroB
       Case 100: Call MacroC
       Case Else:    'do nothing
       End Select
   End If

End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.

---
Regards,
Norman

>I have a worksheet which displays a list of items in column N based on the
> user input in cell C5.
[quoted text clipped - 10 lines]
>
> Phil
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.