ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Worksheet_SelectionChange (https://www.excelbanter.com/excel-programming/302634-worksheet_selectionchange.html)

Rasmus[_2_]

Worksheet_SelectionChange
 
Quick question to all you Excel sharks out there; can I change the following
code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Rows(ActiveCell.Row).Select
End Sub

....to only select the entire row if I actually change ROW and not just
cell/range ?

(c:
Rasmus



William[_2_]

Worksheet_SelectionChange
 
Hi Rasmus

If you move from the cell you have selected and have now selected an entire
row, your code is redundant since you will be selecting the active row. Am I
missing something?

--
XL2002
Regards

William



"Rasmus" wrote in message
ogers.com...
| Quick question to all you Excel sharks out there; can I change the
following
| code:
|
| Private Sub Worksheet_SelectionChange(ByVal Target As Range)
| Rows(ActiveCell.Row).Select
| End Sub
|
| ...to only select the entire row if I actually change ROW and not just
| cell/range ?
|
| (c:
| Rasmus
|
|





William[_2_]

Worksheet_SelectionChange
 
Apologies, I did not read you post properly - try this.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Static v As Variant
If Target.Row < v Then Target.EntireRow.Select
v = Target.Row
End Sub


--
XL2002
Regards

William



"William" wrote in message
...
| Hi Rasmus
|
| If you move from the cell you have selected and have now selected an
entire
| row, your code is redundant since you will be selecting the active row. Am
I
| missing something?
|
| --
| XL2002
| Regards
|
| William
|
|

|
| "Rasmus" wrote in message
| ogers.com...
| | Quick question to all you Excel sharks out there; can I change the
| following
| | code:
| |
| | Private Sub Worksheet_SelectionChange(ByVal Target As Range)
| | Rows(ActiveCell.Row).Select
| | End Sub
| |
| | ...to only select the entire row if I actually change ROW and not just
| | cell/range ?
| |
| | (c:
| | Rasmus
| |
| |
|
|
|
|




All times are GMT +1. The time now is 06:11 AM.

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