Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close button on form
I have a form which opens when excel opens
If Sheets("SearchRoundsData").Range("B2").Value = 1 Then frmWelcome.Hide Else frmWelcome.Show End If On the form there is a close button "CommandButton1". Is it possible to give this button focus so that the user can use the Enter keyboard key rather than having to click with the mouse? Thanks Sandy |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close button on form
in your userform_initialize sub, put
CommandButton1.setfocus hth :) susan On Jul 1, 10:57*am, "Sandy" wrote: I have a form which opens when excel opens * * If Sheets("SearchRoundsData").Range("B2").Value = 1 Then * * * * frmWelcome.Hide * * Else * * * * frmWelcome.Show * * End If On the form there is a close button "CommandButton1". Is it possible to give this button focus so that the user can use the Enter keyboard key rather than having to click with the mouse? Thanks Sandy |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close button on form
Hi Sandy
If you want CommandButton1 to have focus as the userform is shown, right click on the userform, select tab order, bring CommandButton1 to the top. Regards, Per "Sandy" skrev i meddelelsen ... I have a form which opens when excel opens If Sheets("SearchRoundsData").Range("B2").Value = 1 Then frmWelcome.Hide Else frmWelcome.Show End If On the form there is a close button "CommandButton1". Is it possible to give this button focus so that the user can use the Enter keyboard key rather than having to click with the mouse? Thanks Sandy |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close button on form
As usual never just one method :-)
Many thanks to you both. sandy "Sandy" wrote in message ... I have a form which opens when excel opens If Sheets("SearchRoundsData").Range("B2").Value = 1 Then frmWelcome.Hide Else frmWelcome.Show End If On the form there is a close button "CommandButton1". Is it possible to give this button focus so that the user can use the Enter keyboard key rather than having to click with the mouse? Thanks Sandy |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Close button on form
As a user, I'm more used to using the Escape key to do the same as the Cancel
key and the Enter key to the same as the "ok" key. You can accomplish this in your userform_initialize procedure with code like: With Me.CommandButton1 .Caption = "Cancel" .Cancel = True '.Enabled = True End With With Me.CommandButton2 .Caption = "Ok" .Default = True '.Enabled = False End With If you really want to close the userform by hitting enter, you can use .default = true on that commandbutton. (only one commandbutton can have those properties.) Sandy wrote: I have a form which opens when excel opens If Sheets("SearchRoundsData").Range("B2").Value = 1 Then frmWelcome.Hide Else frmWelcome.Show End If On the form there is a close button "CommandButton1". Is it possible to give this button focus so that the user can use the Enter keyboard key rather than having to click with the mouse? Thanks Sandy -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Close X button on Usser Form | Excel Programming | |||
Close user form when button is pressed | Excel Programming | |||
Form Close Button | Excel Programming | |||
Form Close button | Excel Programming | |||
SIMPLEST way to disable "close" button on form? | Excel Programming |