Results 1 to 2 of 2
  1. #1
    5 Star Lounger
    Join Date
    Oct 2001
    Location
    San Bernardino, California, USA
    Posts
    734
    Thanks
    0
    Thanked 0 Times in 0 Posts

    data netry cell order? (2002 - XP)

    Is there a way to control the order of cells visited when the tab key is pressed? I have a worksheet that is protected and the users can only access certain cells. I would like to control the natural order in which they access those cells. Currently, the TAB key moves across the worksheet from left to right and I would like tospecify a particular order of cells.

    Thanks

  2. #2
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: data netry cell order? (2002 - XP)

    You can use the Worksheet_SelectionChange event routine to do this if the number of cells involved is not hugh. Unfortunately, I can not find any way to find out what cell was previously active, only which cell is being selected. So, the code has to look at what cell is being selected and decide from that what cell should be selected. The code below will move the selection from cell A1 to D1 to A2 to D2 to A1, if the sheet is not protected.

    <pre>Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.EnableEvents = False
    Select Case Target.Address
    Case "$B$1"
    ActiveSheet.Range("D1").Select
    Case "$E$1"
    ActiveSheet.Range("A2").Select
    Case "$B$2"
    ActiveSheet.Range("D2").Select
    Case Else
    ActiveSheet.Range("A1").Select
    End Select
    Application.EnableEvents = True
    End Sub
    </pre>


    Another note. This code will drive a user crazy if they are trying to select a cell with the mouse.
    Legare Coleman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •