LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
Mik Mik is offline
external usenet poster
 
Posts: 42
Default Start Macro when specific Cells are selected

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
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
Start Cells with Specific Value Beamers Excel Discussion (Misc queries) 1 March 28th 07 12:22 AM
Macro to start when cell selected JackR Excel Discussion (Misc queries) 5 March 20th 06 04:01 PM
Determine currently selected cells at start of macro Piers 2k Excel Programming 2 March 2nd 05 01:52 PM
Determining Start & End Points in Selected Cells Chris Hankin Excel Programming 4 June 28th 04 12:27 PM
Start a macro from a specific line while editing Bernie Deitrick[_2_] Excel Programming 0 October 7th 03 05:47 PM


All times are GMT +1. The time now is 05:06 PM.

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

About Us

"It's about Microsoft Excel"