View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Move to SELECTED Cells

Private Sub Worksheet_Change(ByVal Target As Range)
Application.MoveAfterReturnDirection = xlToLeft
me.EnableSelection = xlUnlockedCells
If Target.Address = "$C$2" Then Range("G4").Select
If Target.Address = "$G$4" Then Range("C6").Select
If Target.Address = "$C$6" Then Range("E6").Select
'Etc, etc, etc...
End Sub

--
Regards,
Tom Ogilvy


"Danny" wrote in message
...
I unlocked all selected cells and protected the sheet. I
am just wondering that if I use the TAB key, it works. It
also works when you EDIT a cell and press ENTER. Can you
edit my macro so if I press ENTER, it will move to the
next SELECTED cell regardless if I edit the cell or not
(like pressing the TAB key to move to the next selected
cell)?

Thanks in advance.

-----Original Message-----
It doesn't have anything to do with whether the cell

contains an entry or
not. The change event only fires when the user finishes

editing a cell.
The can make a change or not - but if they are in edit

mode and leave it,
then the change event fires. Other than that, your macro

would not have any
effect.

If you want the kind of control you state, you would also

need to use the
selectionchange event and use a static variable to store

the last selection,
then if it meets one of your criteria, move the selection

to the
appropropriate cell (possibly disabling events so you

don't get a recursive
call).

Have you tried unlocking the cells where you want entries

and protecting the
sheet. If that won't give you the order you want, then

perhaps you need to
think about redesigning the layout of your sheet.

--
Regards,
Tom Ogilvy

"Danny" wrote in

message
...
I got this macro from this newsgroup (thank you) that
enables the user to move to selected cells by filling up
the cell or use the tab key:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$2" Then Range("G4").Select
If Target.Address = "$G$4" Then Range("C6").Select
If Target.Address = "$C$6" Then Range("E6").Select
'Etc, etc, etc...
End Sub


However, if the active cells are already filled up and

the
operator uses the ENTER key to move to the next cell, it
doesn't work. Let's say the active cell is C2

(previously
filled-up). If you press enter, the active cell will be

C3
instead of G4.

Please help.



.