ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox SetFocus Problem (https://www.excelbanter.com/excel-programming/276832-re-textbox-setfocus-problem.html)

Tom Ogilvy

TextBox SetFocus Problem
 
SetFocus is available only in userforms.

On a worksheet, I believe you need to use activate.

--
Regards,
Tom Ogilvy

"M." wrote in message
...
Hi world,

i'm using Excel 97. I have two TextBox on sheet, first i wont to type

number
in first text box, then with pressing ENTER, i would like to set focus to
other text box. Why do not apper metod setfocus in suggested list of metod
for textbox?

Thank's!

Milos





Harald Staff[_5_]

TextBox SetFocus Problem
 
From memory, I don't have 97 on this machine: There's a bug in 97 that won't
let you activate one textbox directly from another. So one has to go to a
spreadsheet cell inbetween:

Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
If KeyCode = 9 Or KeyCode = 13 Then
ActiveCell.Activate ' or Select ?
DoEvents
TextBox2.Activate
End If
End Sub

This code crashes my Excel2000 on Windows XP Pro every time, but I think it
was the way to do it with 97.
--
HTH. Best wishes Harald
Excel MVP
Followup to newsgroup only please

"Tom Ogilvy" skrev i melding
...
SetFocus is available only in userforms.

On a worksheet, I believe you need to use activate.

--
Regards,
Tom Ogilvy

"M." wrote in message
...
Hi world,

i'm using Excel 97. I have two TextBox on sheet, first i wont to type

number
in first text box, then with pressing ENTER, i would like to set focus

to
other text box. Why do not apper metod setfocus in suggested list of

metod
for textbox?

Thank's!

Milos








All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com