Control Cursor movement with Tab

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have created a form with Excel. I need to know if I can plan the path of
the cursor so that when the user presses Tab, the cursor goes to a
predetermined cell (Or group of cells) rather than just move logically to the
next unprotected cell.

Thank you
 
Surely can.

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$C$2"
Range("C5").Select
Case "$C$5"
Range("E2").Select
Case "$E$2"
Range("E5").Select
End Select
End Sub

Just keep adding cases and ranges.


Gord
 
Gord,

I use Office XP (Excel XP), I tried both of the methods detailed in this
thread and neither one worked for me. I tried the "case select" with
protection on and I tried the "named range" with protection both on and off.
What am I doing wrong?
 
Only the one method outlined at Bob's site uses sheet protection and unlocked
cells.

The named range method does need sheet protection.

The Case Select method which is now working for you does not use sheet
protection either.

Gord
 
Gord,

Thanks for the quick reply. Now that I know I'm not supposed to use
Worksheet Protection I was all jazzed about finally seeing this work. But...
nothing seems to be controlling the movement of the cursor. Here is my code:

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address
Case "$E$5"
Range("E12").Select
Case "$E$12"
Range("E14").Select
Case "$E$14"
Range("E16").Select
Case "$E$16"
Range("E18").Select
Case "$E$18"
Range("E20").Select
Case "$E$20"
Range("E22").Select
Case "$E$22"
Range("O12").Select
Case "$O$12"
Range("O14").Select
Case "$O$14"
Range("O16").Select
Case "$O$16"
Range("O18").Select
Case "$O$18"
Range("V12").Select
Case "$V$12"
Range("V14").Select
Case "$V$14"
Range("V16").Select
Case "$V$16"
Range("V18").Select
Case "$V$18"
Range("R12").Select
Case "$R$12"
Range("R14").Select
Case "$R$14"
Range("R16").Select
Case "$R$16"
Range("R18").Select
Case "$R$18"
Range("X12").Select
Case "$X$12"
Range("X14").Select
Case "$X$14"
Range("X16").Select
Case "$X$16"
Range("X18").Select
Case "$X$18"
Range("E5").Select
End Select
End Sub

One thing I noticed was the Private Sub naming. By default my Visio Studio
provided "Worksheet_SelectionChange(ByVal Target As Range)", but your example
uses "Worksheet_Change". Have I introduced an error? And where can I read
about the function Target.Address?

Thanks again for your assistance.
 
Back
Top