Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 17 Nov, 18:37, Gord Dibben <gorddibbATshawDOTca wrote:
Substitute msgbox for your code or macro. Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Intersect(Target, Me.Range("C3,C4,C5")) Is Nothing Then Exit Sub MsgBox Target.Address End Sub Gord Dibben *MS Excel MVP On Tue, 17 Nov 2009 02:47:12 -0800 (PST), Mik wrote: On 17 Nov, 09:43, Mik wrote: I have a range of cells b3:b5 which show UserNames of people who will use the spreadsheet. The adjacent cells c3:c5 allow a manual input from the user. The user must enter the info in their specific adjacent cell only. So, when any of these cells c3:c5 are selected, i wish to run a macro (preferably before user input) which will check to see that the current user is entering info within the correct cell. I determine the user with the Environ("username") function. For info, i am using Excel 2007. My code at present is:- Private Sub Worksheet_Change(ByVal Target As Range) * * If Target.Address = "$c$3" Then * * * * If Range("b3").Value = Environ("username") Then 'allow entry * * * * * * Exit Sub * * * * Else * * * * * * MsgBox ("Wrong User Input!") * * * * End If * * Else 'code to repeat for $c$4, and $c$5 etc... * * End If End Sub Sorry, When I look back at my previous entry it does not read very clear. Basically, can anybody advise me how to Run a Macro when a specific cell is selected, using Excel 2007? Macro must run before text is entered into the cell. Thanks in advance. Mik- Hide quoted text - - Show quoted text - Thank you both very much for your assistance. That did exactly what i wanted. Mik |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Start Cells with Specific Value | Excel Discussion (Misc queries) | |||
Macro to start when cell selected | Excel Discussion (Misc queries) | |||
Determine currently selected cells at start of macro | Excel Programming | |||
Determining Start & End Points in Selected Cells | Excel Programming | |||
Start a macro from a specific line while editing | Excel Programming |