ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Identifying the Selected Cell (https://www.excelbanter.com/excel-programming/346432-identifying-selected-cell.html)

Warderbrad

Identifying the Selected Cell
 

I am needing a set of code to run when a range of cells have one of them
changed, and I am not sure how to event this.

I had thought to use a Selection_Change event but I am still not sure
how to tell what cell is/was selected. Is there a standard command to
retrieve the address of either the newly selected cell or the one being
moved away from?


--
Warderbrad
------------------------------------------------------------------------
Warderbrad's Profile: http://www.excelforum.com/member.php...o&userid=28169
View this thread: http://www.excelforum.com/showthread...hreadid=487652


antoka05[_5_]

Identifying the Selected Cell
 

in selection change you can use this code:
for i=0 to target.count - 1
selectedRow=target(i).row +1
selectedColumn=target(i).column
next

I didn't try it but i think it's correct


--
antoka05
------------------------------------------------------------------------
antoka05's Profile: http://www.excelforum.com/member.php...o&userid=29024
View this thread: http://www.excelforum.com/showthread...hreadid=487652


Bob Phillips[_6_]

Identifying the Selected Cell
 
If you use the Worksheet_Change event the changed cell is passed toi the
event procedure as a parameter.

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo ws_exit:
Application.EnableEvents = False
With Target
'do your stuff
End If

ws_exit:
Application.EnableEvents = True
End Sub

'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.

In this example, Target refers to the cell changed.


--

HTH

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


"Warderbrad" wrote
in message ...

I am needing a set of code to run when a range of cells have one of them
changed, and I am not sure how to event this.

I had thought to use a Selection_Change event but I am still not sure
how to tell what cell is/was selected. Is there a standard command to
retrieve the address of either the newly selected cell or the one being
moved away from?


--
Warderbrad
------------------------------------------------------------------------
Warderbrad's Profile:

http://www.excelforum.com/member.php...o&userid=28169
View this thread: http://www.excelforum.com/showthread...hreadid=487652





All times are GMT +1. The time now is 01:10 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com