Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
row and cell highlighted Mr.Param[_2_] Excel Worksheet Functions 2 July 14th 09 09:26 AM
Excel 2007 Record Macro button in Developer tab is not highlighted Golfnjohn Excel Discussion (Misc queries) 0 April 30th 08 09:31 PM
Is there a macro which adds selected/highlighted cells? Ed Excel Worksheet Functions 2 September 28th 05 01:36 PM
Every cell is highlighted 5hulses Excel Discussion (Misc queries) 5 May 1st 05 11:27 PM
Highlighted Cell Dave Excel Discussion (Misc queries) 0 May 1st 05 05:40 PM


All times are GMT +1. The time now is 07:16 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"