Results 1 to 1 of 1

Thread: Spreadsheet Tab Control

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    6

    Post Spreadsheet Tab Control

    I am looking for any help to tell me how to "map" the tab key to a specific order through unprotected cells on an excel worksheet. I have enclosed the workbook to demonstrate my request. Sheet1 (EC Template) is the "form" and Sheet2 is the map order of the cells corresponding to unlocked cells on Sheet1. I don't want the User to be taken to the shaded area to the right of the "form" though I do have to leave those cells unprotected....I want to bypass having them going to them using the tab key. Hope this is clear enough - i've included the code below that I've attempted to write but unfortunately doesn't work...


    Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
    '***************************************************************************************
    'Tab Cell Map designed to flow through the EC Template sheet without tabbing into the
    'Lookup tables.
    '***************************************************************************************

    'Declare Variables
    Dim TabCellMap As Range, cell As Range, Fn As Object, x As Integer


    Application.EnableEvents = False

    'Initialize
    Set Fn = Application.WorksheetFunction
    Set TabCellMap = Sheet2.Cells.SpecialCells(xlConstants, xlNumbers)

    x = 1

    'Error Correction call
    On Error GoTo errhand
    If Target.Row < LastAddr.Row Or Target.Column < LastAddr.Column Then x = -1 Else x = 1

    'Start the Map
    n = n + x
    If n = Fn.Max(TabCellMap) + 1 Then n = 1
    If n < 1 Then n = Fn.Max(TabCellMap)
    'Continue loop
    For Each cell In TabCellMap
    If cell.Value = n Then
    TabAddr = cell.Address
    Exit For
    End If
    Next cell

    Sheet1.Range(TabAddr).Select
    Application.EnableEvents = True

    Exit Sub

    errhand:
    Set LastAddr = Target
    Resume
    End Sub

    Sub enable_events()

    Application.EnableEvents = True
    End Sub
    Attached Files Attached Files
    Last edited by Ammbassador777; Jan 26th, 2012 at 03:23 PM.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width