ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   TextBox Focus (https://www.excelbanter.com/excel-programming/300326-re-textbox-focus.html)

Tom Ogilvy

TextBox Focus
 
Private Sub CommandButton1_Click()
If Sheet1.TextBox1.Value = "" Then
MsgBox "Please enter a name"
Sheet1.TextBox1.Activate
End If

End Sub

Worked fine for me in Excel 2000.

I don't know what fires the code, where it is located, or what version of
Excel you are using, but as I said, there is nothing inherently wrong with
the code suggested.

--
Regards,
Tom Ogilvy

"ené" wrote in message
...
Hi every one!

Thanks Tom for your help, but it did not work. I did exactly what you

suggested.

If Sheet1.TextBox1.Value = "" Then
MsgBox "Please enter a name"
Sheet1.TextBox1.Activate
End If

This is the error message:

Run-time error '1004':

Activate method of OLEOobject class failed

Thanks in advance to all!!!





All times are GMT +1. The time now is 12:29 PM.

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