click button on userform after certain time

birdman

Board Regular
Joined
Oct 11, 2005
Messages
187
does anyone know the code to click a commandbutton that is on a userform lets say 10 seconds after that userform is opened if the user does not take any action??
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
birdman,
You could setup a ontime command in the form_initialize, that would execute the same code as the button after your 10 second time delay.

HTH
Cal

PS-There are also custom controls available with this functionality.
 
Upvote 0
ok so it has to be done in userform_initialize. if possible, can you provide an example on how the code would look because i am not familiar with the ontime command.
 
Upvote 0
i am guessing something like this but i dont know how to call the commandbutton.
Code:
Application.OnTime Now + TimeValue("00:00:10")
does anyone know how to call the commandbutton to be clicked and run?
 
Upvote 0
birdman,
I would not call the button_click event, I would have the button_click event and your ontime code, call the same macro.

Ex

sub Commandbutton_1_Click()'This is not the actual event, just for display!!!
Application.OnTime Now + TimeValue("00:00:10") 'I've never used the ontime, so I'm not sure of the structure. I do know there is lots of help about it on this board.
ExecuteCode
End Sub

Sub UserForm1_initialize()'Again, not the real event call, just an example
ExecuteCode
End Sub

Sub ExecuteCode()
'Your Code Here
End sub

HTH
Cal
 
Upvote 0

Forum statistics

Threads
1,214,944
Messages
6,122,384
Members
449,080
Latest member
Armadillos

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