#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cell Select

Is there a way to determine if a cell is selected? I tried to use the
onchange event, but that only works when something is changed. If a certain
cell is selected, I would like to test and make sure another cell has data
in it.

For example, the user must choose a value from a data validation drop down
list in cell C7 before the cascading list in cell D8 is populated. If they
try to select cell D8 first, I want to display a message and then set cell
C7 as the active cell.

I'm not sure if there is a way to capture a cell select versus a change???

Thanks,

Tom


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Cell Select

Use the selectionchange event in xl97 and later

See Chip Pearson's page on events
http://www.cpearson.com/excel/events.htm

Also, if you change the selection within the SelectionChange event, you
should disable events (reenable them at the end) within the event to prevent
recursive calls.

--
Regards,
Tom Ogilvy

"Tom Melosi" wrote in message
...
Is there a way to determine if a cell is selected? I tried to use the
onchange event, but that only works when something is changed. If a

certain
cell is selected, I would like to test and make sure another cell has data
in it.

For example, the user must choose a value from a data validation drop down
list in cell C7 before the cascading list in cell D8 is populated. If

they
try to select cell D8 first, I want to display a message and then set cell
C7 as the active cell.

I'm not sure if there is a way to capture a cell select versus a change???

Thanks,

Tom




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Cell Select

Try the worksheet select event

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$D$8" Then
With Target
'do your stuff
End With
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Tom Melosi" wrote in message
...
Is there a way to determine if a cell is selected? I tried to use the
onchange event, but that only works when something is changed. If a

certain
cell is selected, I would like to test and make sure another cell has data
in it.

For example, the user must choose a value from a data validation drop down
list in cell C7 before the cascading list in cell D8 is populated. If

they
try to select cell D8 first, I want to display a message and then set cell
C7 as the active cell.

I'm not sure if there is a way to capture a cell select versus a change???

Thanks,

Tom




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cell Select

Thanks, worked great!

"Bob Phillips" wrote in message
...
Try the worksheet select event

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$D$8" Then
With Target
'do your stuff
End With
End If
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cell Select

The selectionchange event is what I was looking for - Thanks!

"Tom Ogilvy" wrote in message
...
Use the selectionchange event in xl97 and later

See Chip Pearson's page on events
http://www.cpearson.com/excel/events.htm

Also, if you change the selection within the SelectionChange event, you
should disable events (reenable them at the end) within the event to

prevent
recursive calls.

--
Regards,
Tom Ogilvy





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cell Select


Use

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'Target will be the range of the selected cell
If target.row = [row number] and target.column = [column number
then
[your code]
End If
End Sub

or something like tha

--
TommySzalapsk
-----------------------------------------------------------------------
TommySzalapski's Profile: http://www.excelforum.com/member.php...fo&userid=2556
View this thread: http://www.excelforum.com/showthread.php?threadid=38994

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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
How to point to (select) a cell to the left from a cell where I enter the = equal sign? Dmitry Excel Discussion (Misc queries) 4 June 30th 06 06:49 AM
I cannot select a single cell or pull down cell contents Carolyn Fahm Excel Worksheet Functions 0 January 24th 06 04:54 PM
Select cell, Copy it, Paste it, Return to Previous cell spydor Excel Discussion (Misc queries) 1 December 30th 05 01:29 PM


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

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"