View Full Version : Solved: move to textbox in other sheet if is "TAB" pressed
danovkos
10-14-2009, 01:25 AM
Hi all,
pls. how can i do following.
I want anytime, whne i press key TAB in sheet "view" to move to my TEXTbox in sheet "ALL".
I tried this, but it didnt works :(
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Sheets = Sheets("view").Select Then
With TextBoxALL
If KeyCode = vbKeyTab Then
With TextBoxALL
TextBoxALL.Value = ""
Call VlozCIFdoVIEW_Click
End If
End With
End Sub
Greetings danovkos,
Just a start, but see if this is on the right path...
In a throwaway copy of your wb:
Change the codename of the sheet named (tab name) "ALL" to 'shtAll'.
In the worksheet module for "View":
Option Explicit
Private Sub Worksheet_Activate()
Application.OnKey "{TAB}", "GoToTextBox"
End Sub
Private Sub Worksheet_Deactivate()
Application.OnKey "{TAB}"
End Sub
In a Standard Module:
Option Explicit
Sub GoToTextBox()
shtAll.Activate
'// Change to codename of textbox //
shtAll.TextBox1.Activate
End Sub
I would also incude code in Workbook_Deactivate abd Workbook_Activate.
Does that help?
Mark
danovkos
10-14-2009, 05:52 AM
thx for try :)
this code return error - variable not defined
and stops - debug in this code
Sub GoToTextBox()
shtAll.Activate
'// Change to codename of textbox //
shtAll.TextBoxALL.Activate
' All.TextBoxALL.Activate
End Sub
on row
shtAll.Activate
and question
is it neccessary to rename my sheet "ALL" to "shtALL" because i have more codes with shotcut to this sheet ALL
thx
Hi there,
I did not say to rename the sheet. I said to change the sheet's codename. While sheet "All" is active, right-click the sheet's tab and select View Code.
In the properties window, you will see that the worksheet has two Name properties. The one at the top with the parenthesis around it is the sheet's codename. Change that one; it will not affect code that refers to the worksheet name.
Mark
danovkos
10-14-2009, 06:16 AM
sorry i didnt understand it first time..:banghead:
but great it works very good as i wish :clap: :rotlaugh: :bow:
thank you very much for you time and help
Dear Danovkos,
I just looked at my last as well as your response. If I sounded the least bit terse, that was not my intent and my apologies if you took it that way.
I am glad it is working, adn remember what I said about the workbook activate/deactivate events. This way if you have two workbooks open, we don't accidently leave the OnKey calling the procedure. Maybe something like:
In ThisWorkbook Module:
Option Explicit
Private Sub Workbook_Activate()
If ActiveSheet.Name = "View" Then
Application.OnKey "{TAB}", "GoToTextBox"
End If
End Sub
Private Sub Workbook_Deactivate()
Application.OnKey "{TAB}"
End Sub
A great day to your and yours,
Mark
danovkos
10-14-2009, 06:38 AM
thank you
have a nice day
danovkos
10-14-2009, 11:57 PM
i dont know, but it sometimes doesnt works after opening wb:dunno :(
know anyone where can be a problem?
danovkos
10-15-2009, 01:35 AM
now i figured out, that it doesnt works after start
but when i click on other tab and return in sheet view, it start working
???
Sorry about that. I just spotted that you have the sheet named in lower-case. Change to:
Private Sub Workbook_Activate()
If ActiveSheet.Name = "view" Then
Application.OnKey "{TAB}", "GoToTextBox"
End If
End Sub
I think that should catch it :-)
Mark
danovkos
10-15-2009, 02:35 AM
thx, but it doesnt helps.
but it helps, when i add this code to
"thisworksbook"
Private Sub Workbook_Open()
...
Application.OnKey "{TAB}", "GoToTextBox"
...
now it works immediately :)
but thx
Gosh Danovkos, that's a mystery to me. Even in my 'poor ol' laptop' the wb activate and deactivate events occur w/o anything in wb_open.
Just to make sure, I tested:
Option Explicit
Private Sub Workbook_Activate()
MsgBox "Workbook_Activate()"
End Sub
Private Sub Workbook_Deactivate()
MsgBox "Workbook_Deactivate()"
End Sub
Both fired. Well anyways, sure glad its working now:thumb
Mark
danovkos
10-15-2009, 05:20 AM
OK
thank you for your help.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.