Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to get the correct active Cell position in Worksheet_Change

In a Excel Cell (A1), if we type 123 [ENTER]

then the code bellow will
Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox ActiveCell.Address
End Sub

output A2 or B1 (depent on the direction of the cursor we set in
Tools/Option/Edit/Direction after selection (down, right,....)
Which is not what I wanted! (I wanted A1......)

question : How to get (to modify) the content of A1 (like a VALID clause in
VB)...
which we will doing a validation before leaving the cell..........

thanks so much!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How to get the correct active Cell position in Worksheet_Change

You don't want ActiveCell.Address, you want Target.Address.



--
Gary''s Student - gsnu200771


"Johan2000" wrote:

In a Excel Cell (A1), if we type 123 [ENTER]

then the code bellow will
Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox ActiveCell.Address
End Sub

output A2 or B1 (depent on the direction of the cursor we set in
Tools/Option/Edit/Direction after selection (down, right,....)
Which is not what I wanted! (I wanted A1......)

question : How to get (to modify) the content of A1 (like a VALID clause in
VB)...
which we will doing a validation before leaving the cell..........

thanks so much!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default How to get the correct active Cell position in Worksheet_Chang



"Gary''s Student" wrote:

You don't want ActiveCell.Address, you want Target.Address.



--
Gary''s Student - gsnu200771


"Johan2000" wrote:

In a Excel Cell (A1), if we type 123 [ENTER]

then the code bellow will
Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox ActiveCell.Address
End Sub

output A2 or B1 (depent on the direction of the cursor we set in
Tools/Option/Edit/Direction after selection (down, right,....)
Which is not what I wanted! (I wanted A1......)

question : How to get (to modify) the content of A1 (like a VALID clause in
VB)...
which we will doing a validation before leaving the cell..........

thanks so much!


MsgBox ActiveCell.Address // position after ENTER
MsgBox Target.Address // position before ENTER


You just make my day :)

Say thanks to Your GURU Gary!
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
Active cell position for macro MechEng Excel Worksheet Functions 3 September 24th 07 01:44 PM
API to find position of active cell no longer working in 2007. GollyJer Excel Programming 5 June 13th 07 09:29 PM
move within ss by active cell position, NOT by cell names BEEJAY Excel Programming 2 August 23rd 06 04:34 PM
In macros, an instruction that will return the position of the Active Cell aca[_4_] Excel Programming 2 January 20th 06 10:50 PM
Active Cell Position Using Go To Or Hyperlink Keith Chipman Excel Programming 1 November 19th 03 03:05 PM


All times are GMT +1. The time now is 04:34 AM.

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"