Automatically executing InputBox() after "Userform.Show" Command

csv27

New Member
Joined
Nov 23, 2016
Messages
4
Hey all,

As per the title, I'm trying to figure out how to automatically ask the user to input data after I show a Userform.

Relevant Code:

Private Sub Start_Click()

Userform.Show
number = InputBox("Please enter a number", "Enter a number")

End Sub


When I execute the above code, it stops at Userform.Show. I don't want to add a command button... But if that's the only way so be it... Unless there's a way!

Thank you for any help. Cheers!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

Maybe !!!
Code:
UserForm[B][COLOR=#FF0000]1[/COLOR][/B].Show
 
Upvote 0
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

Sorry, I renamed Userform1 to Userform... Is there still a way?
 
Upvote 0
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

try:

Code:
Private Sub Start_Click()


    UserForm.Show vbModeless
    Number = InputBox("Please enter a number", "Enter a number")


End Sub

and see if this does what you want.

Dave
 
Last edited:
Upvote 0
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

Hi

Code:
Private Sub UserForm_Activate()
DoEvents
Number = InputBox("Please enter a number", "Enter a number")
End Sub

I found this works form me?

dave
 
Upvote 0
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

sorry

this one

Code:
Private Sub UserForm_Activate()
DoEvents
    Number = InputBox("Please enter a number", "Enter a number")
End Sub
 
Upvote 0
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

It most certainly did, thanks for your help!

try:

Code:
Private Sub Start_Click()


    UserForm.Show vbModeless
    Number = InputBox("Please enter a number", "Enter a number")


End Sub

and see if this does what you want.

Dave
 
Upvote 0
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

Try this in Userform Module:-
Code:
Private Sub UserForm_Initialize()
Dim Number As Long
Number = InputBox("Please enter a number", "Enter a number")
End Sub
 
Upvote 0
Re: HELP: Automatically executing InputBox() after "Userform.Show" Command

Unfortunately DoEvents did not work for me, but I do appreciate you helping.
sorry

this one

Code:
Private Sub UserForm_Activate()
DoEvents
    Number = InputBox("Please enter a number", "Enter a number")
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

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