View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default how to confine the range of movement of cursor

Here is some VBA top do it

Dim oldCell As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Row 50 Or Target.Column 22 Then
If Not oldCell Is Nothing Then
oldCell.Activate
Else
Me.Range("A1").Activate
End If
Else
Set oldCell = Target
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"starwil" wrote in message
...
for example, if i just want to let the cursor in worksheet move from

column
A to V and / or row 1 to 50,
how to setup?