Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet_SelectionChange & Worksheet_Change results in different Targets

I find following strange behaviour in Excel 2013. Using Ctrl-C the target range in Worksheet_Change is correct, but when I use Ctrl-X the target range in Worksheet_Change becomes the active cell only. Here are immediate window results:

Select a cell, Ctrl-C, select three other cells, and Ctrl-V:

Worksheet_SelectionChange's Target.Address: $A$4
Worksheet_SelectionChange's Target.Address: $B$4:$B$6
Worksheet_Change's Target.Address: $B$4:$B$6

Select a cell, Ctrl-X, select three other cells, and Ctrl-V:

Worksheet_SelectionChange's Target.Address: $A$4
Worksheet_SelectionChange's Target.Address: $C$4:$C$6
Worksheet_Change's Target.Address: $A$4
Worksheet_Change's Target.Address: $C$4
Worksheet_SelectionChange's Target.Address: $C$4


Following events used:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Debug.Print "Worksheet_SelectionChange's Target.Address: " & Target.Address
End Sub

Sub Worksheet_Change(ByVal Target As Range)
Debug.Print "Worksheet_Change's Target.Address: " & Target.Address
End Sub


Is there any of you who know how to get the full selected range in Worksheet_Change?

Thanks,
Skogstrom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 147
Default Worksheet_SelectionChange & Worksheet_Change results in differentTargets

wrote:
I find following strange behaviour in Excel 2013. Using Ctrl-C the target range in Worksheet_Change is correct, but when I use Ctrl-X the target range in Worksheet_Change becomes the active cell only. Here are immediate window results:

Select a cell, Ctrl-C, select three other cells, and Ctrl-V:

Worksheet_SelectionChange's Target.Address: $A$4
Worksheet_SelectionChange's Target.Address: $B$4:$B$6
Worksheet_Change's Target.Address: $B$4:$B$6

Select a cell, Ctrl-X, select three other cells, and Ctrl-V:

Worksheet_SelectionChange's Target.Address: $A$4
Worksheet_SelectionChange's Target.Address: $C$4:$C$6
Worksheet_Change's Target.Address: $A$4
Worksheet_Change's Target.Address: $C$4
Worksheet_SelectionChange's Target.Address: $C$4


Following events used:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Debug.Print "Worksheet_SelectionChange's Target.Address: " & Target.Address
End Sub

Sub Worksheet_Change(ByVal Target As Range)
Debug.Print "Worksheet_Change's Target.Address: " & Target.Address
End Sub


Is there any of you who know how to get the full selected range in Worksheet_Change?

Thanks,
Skogstrom



That is correct and works the same way in other versions.

When you select one cell and copy it to larger range, content of
selected cell is duplicated in every cell of target range.

The same apply to row.
Select i.e. 2 cells (1 row, 2 cols) and paste it to range 5 rows by 2
cols. Each row will have the same duplicated values.

That is how copy works. It duplicates value(s) (if it can be done).

Sometimes it can't be done. Try to copy 2 x 2 to 3 x 3 range.
This time only 2 x 2 range will be copied and last row and last column
will stay untouched.


Cut function does not duplicated anything. One selected cell will land
only in top left corner of selected range and other cell will not change.

You immediate window shows correct addresses.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Worksheet_SelectionChange & Worksheet_Change results in different Targets

Thank you for the confirmation!
/tskogstrom
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
How is Worksheet_SelectionChange Work Different From Worksheet_Change? Minitman Excel Programming 0 May 15th 08 12:55 AM
Sum To Work Out Targets Mikey2005 Excel Discussion (Misc queries) 1 February 23rd 06 08:38 PM
Worksheet_Change or Worksheet_SelectionChange Bret Excel Programming 2 September 27th 05 12:55 AM
Worksheet_Change sub causes funny results MWE Excel Programming 2 January 17th 04 04:46 AM


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