View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Norman Jones Norman Jones is offline
external usenet poster
 
Posts: 5,302
Default Run macro when cell is highlighted.

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


"Defoes Right Boot" wrote in
message ...
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