View Full Version : Solved: Tab
ukdane
05-28-2010, 02:09 AM
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
Bob Phillips
05-28-2010, 02:31 AM
How about this
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$M$5" Then
Me.TextBox1.Activate
End If
End Sub
ukdane
05-28-2010, 03:29 AM
Sounds like a plan, I'll give it a go.
Any ideas about tabbing out of it afterwards, and into the next cell?
Cheers
Bob Phillips
05-28-2010, 03:45 AM
No, I don't think you can via code as there is no such event.
ukdane
05-28-2010, 03:58 AM
To confirm
This works: Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.EnableEvents = True
If Target.Address = "$C$1" Then
Me.ComboBox1.Activate
End If
End Sub
I was looking at
Private Sub ComboBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 9 Then
Me.Range("F3").Activate
KeyAscii = 0
Else
End If
End Sub
To tab out, but as you say, pressing the tab key, doesn't even register.
Bob Phillips
05-28-2010, 04:03 AM
This seems to work
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
ukdane
05-28-2010, 05:08 AM
Yes it does indeed.
Thanks for your help.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.