UserForm

G

Guest

I have a UserForm that has a drop box with all of the worksheet names in the
drop box. When the user clicks the worksheet name, that worksheet becomes
the active sheet on the screen.

However, the cursor focus stays in the drop box and I want the focus and the
cursor to go the the worksheet. The UserForm should lose the focus and Excel
and the worksheet should get the focus. NO LUCK!

Please help.
 
D

Dave Peterson

I created a small userform with a combobox and a commandbutton (to cancel) on
them.

This code showed the form:
Option Explicit
Sub testme()
UserForm1.Show vbModeless
End Sub

This code was behind the userform:

Option Explicit
Private Sub ComboBox1_Change()
On Error Resume Next
Sheets(Me.ComboBox1.Value).Select
If Err.Number <> 0 Then
MsgBox "Error Selecting sheet: " & Me.ComboBox1.Value
Err.Clear
End If
On Error GoTo 0
AppActivate Application.Caption
End Sub
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim wks As Object
For Each wks In ActiveWorkbook.Sheets
Me.ComboBox1.AddItem wks.Name
Next wks
End Sub

========
Another idea would be to use a floating toolbar.

If you want to look into that, here's a link to an old post.
http://groups.google.com/[email protected]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top