Worksheet_SelectionChange & Worksheet_Change results in different Targets

  • Thread starter Thread starter tskogstrom
  • Start date Start date
T

tskogstrom

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
 
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.
 
Back
Top