Consulting

Results 1 to 7 of 7

Thread: Solved: Tab

  1. #1
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location

    Solved: Tab

    Is it possible to program a tab function so that if a user is tabbing from cell to cell, that at some point, if they press tab, instead of tabbing into a cell, the tab moves into a shape (in my case a dropdown box), and then tab out of it into another cell.
    Kind of like the tab index on a form, except without the form.

    Thanks in advance

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    How about this

    [vba]

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$M$5" Then

    Me.TextBox1.Activate
    End If
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    Sounds like a plan, I'll give it a go.
    Any ideas about tabbing out of it afterwards, and into the next cell?

    Cheers

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    No, I don't think you can via code as there is no such event.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    To confirm

    This works: [VBA]Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Application.EnableEvents = True
    If Target.Address = "$C$1" Then
    Me.ComboBox1.Activate
    End If
    End Sub[/VBA]

    I was looking at
    [VBA]Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
    If KeyAscii = 9 Then
    Me.Range("F3").Activate
    KeyAscii = 0
    Else
    End If
    End Sub[/VBA]
    To tab out, but as you say, pressing the tab key, doesn't even register.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    This seems to work

    [vba]

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$C$1" Then

    Me.ComboBox1.Activate
    End If
    End Sub

    Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
    ByVal Shift As Integer)
    If KeyCode = vbKeyTab Then

    Me.Range("D1").Select
    End If
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Mentor
    Joined
    Nov 2008
    Posts
    305
    Location
    Yes it does indeed.
    Thanks for your help.

Posting Permissions

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