UserForm Help

steve1262

Board Regular
Joined
Aug 19, 2006
Messages
126
I have started a userform and I am having some problems. So far

I have 2 command buttions that allow the user the change the direction of the cell on enter.

This code is in the userform location
Code:
Private Sub CommandButton1_Click()
Application.MoveAfterReturnDirection = xlToRight
End Sub

Private Sub CommandButton2_Click()
Application.MoveAfterReturnDirection = xlDown
End Sub

I also have a code to open the userform when the wookbook opens.

Code:
Private Sub Workbook_Open()
 UserForm1.Show
End Sub

I have this in the "ThisWorkBook" location.

The code seem to work but it will not allow me to return back the worksheet, it seems to "lock up". I have to exit the userform to get back to the worksheet. I want to leave the userform open.

I tried selecting the worksheet but did not have any luck.

What am I doing worng?

Thank you.

Steve
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Private Sub Workbook_Open()
UserForm1.Show vbmodeless
End Sub

If you run a version excel later than 97 you can use the above code to open a modeless form, allowing interaction with excels worksheets as well as the form.
 
Upvote 0
Steve

Wouldn't it be better to have this functionality on a toolbar rather than a userform?
 
Upvote 0
Hello Steve,
You haven't done anything wrong.
Userforms are by default shown in the modal state.
What you want to do is stipulate upon loading it that you want it shown in the non-modal state.

Try changing your workbook open code to:
Code:
Private Sub Workbook_Open()
 UserForm1.Show vbModeless
End Sub

This will allow user interaction with the worksheet while the userform is showing.

(Check out the help files for "Modal" & "Non Modal" for the ups & downs of using this)
 
Upvote 0
Thank you all for the quick response.

Norie I agree with you about the toolbar but this is just the start of a multi-part userform and I want to have everything in one place.

Both Patrick's and HalfAce suggestions worked and the form is visable. However I still have to "click on" the worksheet to make it active. Is there any way to have the code do this?

Thank you all for your response.

Steve
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,974
Members
448,537
Latest member
Et_Cetera

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top