Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run macro when cell is highlighted.
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
row and cell highlighted | Excel Worksheet Functions | |||
Excel 2007 Record Macro button in Developer tab is not highlighted | Excel Discussion (Misc queries) | |||
Is there a macro which adds selected/highlighted cells? | Excel Worksheet Functions | |||
Every cell is highlighted | Excel Discussion (Misc queries) | |||
Highlighted Cell | Excel Discussion (Misc queries) |