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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

patrickmuldoon99

Active Member
Joined
Jun 27, 2006
Messages
345
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.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,300
Office Version
  1. 365
Platform
  1. Windows
Steve

Wouldn't it be better to have this functionality on a toolbar rather than a userform?
 

HalfAce

MrExcel MVP
Joined
Apr 6, 2003
Messages
9,454
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)
 

steve1262

Board Regular
Joined
Aug 19, 2006
Messages
126
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
 

Forum statistics

Threads
1,137,205
Messages
5,680,184
Members
419,887
Latest member
Vasokir

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
Top