![]() |
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 |
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 |
All times are GMT +1. The time now is 09:30 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com