Okay, I see what you mean. If you pick a cell (or several cells assuming the
"If Target.Count" test I later proposed is not in use), then that process
kicks off the SelectionChange event and, when its code selects the entire
row, that, in turn, kicks off another SelectionChange event. On the other
hand, if you select the entire row directly, only one SelectionChange event
is kicked off as executing the entire row selection in code does nothing to
change the selection, so no second SelectionChange event takes place.
So, your suggested use of Application.EnableEvents seems like the best way
to go here; although its use would only really be significant if other code
is to be executed within the SelectionChange event. I don't think the error
handler you originally suggested would be needed (at least not for the
snippet of code I suggested) as I can't see where the error would be
generated from this...
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
Application.EnableEvents = False
Target.EntireRow.Select
Target.Activate
Application.EnableEvents = True
End Sub
As I hinted above, though, those Application.EnableEvents statements could
be removed, and the subsequent second call to the event procedure tolerated,
as doing so would produce no real harm. Executing the two
Application.EnableEvents statements might very well be as costly, time-wise,
as simply letting the SelectionChange event fire off twice without them.
Now, however, if the programmer were to add other code to this procedure,
then all bets are off... the Application.EnableEvents, as well as some error
handling code, may be required by this additional code in order to protect
it.
Thanks for your input in this thread (and staying with me through my "dense
period"<g>); I really appreciated it.
Rick