Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ?row and ?key -- Worksheet_Change

Hi All,

I can programatically get the address after a sheet change
with the Worksheet_Change event such as the code below,

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Debug.Print ActiveCell.Address(ReferenceStyle:=xlR1C1)

End Sub

But how can I get the row and col that the change occurred on?

And/or how can you tell what keystroke was used to exit the cell?

i.e. if you hit TAB to leave a cell the address method above returns
the correct row but the col is wrong and has been advanced. If you
hit the ENTER to leave a cell the address method above returns
the correct col but the row is wrong and has been advanced.

e.g. if you change R14C9 and hit TAB, .address returns R14C10
if you change R14C9 and hit ENTER, .address returns R15C9

and not knowing which key was used means you have no idea
what the changed row and col was? There must be a way.......

mtnw


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default ?row and ?key -- Worksheet_Change

I think I found my own answer finally:

Target.AddressLocal(ReferenceStyle:=xlR1C1)

Let me know if this is wrong.

mtnw



"mtnw" wrote:

Hi All,

I can programatically get the address after a sheet change
with the Worksheet_Change event such as the code below,

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Debug.Print ActiveCell.Address(ReferenceStyle:=xlR1C1)

End Sub

But how can I get the row and col that the change occurred on?

And/or how can you tell what keystroke was used to exit the cell?

i.e. if you hit TAB to leave a cell the address method above returns
the correct row but the col is wrong and has been advanced. If you
hit the ENTER to leave a cell the address method above returns
the correct col but the row is wrong and has been advanced.

e.g. if you change R14C9 and hit TAB, .address returns R14C10
if you change R14C9 and hit ENTER, .address returns R15C9

and not knowing which key was used means you have no idea
what the changed row and col was? There must be a way.......

mtnw


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
Worksheet_Change Jive Excel Worksheet Functions 2 June 11th 07 10:03 AM
Worksheet_Change DDE Johan de Kok Excel Programming 2 April 23rd 05 06:32 PM
Worksheet_change won't run Eric Excel Discussion (Misc queries) 4 March 10th 05 03:43 PM
worksheet_change vs. calculate, and worksheet_change not running Tom Ogilvy Excel Programming 1 July 14th 03 02:51 AM
worksheet_change vs. calculate, and worksheet_change not running Ross[_5_] Excel Programming 0 July 13th 03 04:27 PM


All times are GMT +1. The time now is 07:57 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"