Very hard question

buntykins

Board Regular
Joined
Apr 11, 2002
Messages
76
I need some code for my userform to perform an action. I dont think it's possible, but it's worth asking.

When I click a command button, I need it to unload the userform, then make it open again 2 minutes later. Then it remains open until the button is pressed again.

I tried using OnTime but it kept looping and I just need it to happen once, when the button is pressed

Does anyone know how I can do this?

Janie
:confused:
:confused:
:confused:
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi. Why dont't you use flag?

<pre>
'Standerd module
Dim flg As Boolean
Sub Test()
UserForm1.Show
End Sub

Sub ReLoad()
If Not flg Then UserForm1.Show
flg = True
End Sub

'Userform1 Module

Private Sub CommandButton1_Click()
Unload Me
Application.OnTime Now + TimeValue("00:02:00"), "ReLoad"
End Sub
</pre>
 
Upvote 0
That's crazy, I was just testing something similar!!

Mine's a little cruder than yours. Mine is:

'userform module
Unload Me
Application.OnTime Now+TimeValue("00:02:00"),"Againplease"

'Standard Module
sub Againplease()
Userform1.show
End sub

Mine works fine. What are the benefits of having flags? If they're beneficial I'll use your's

Thnaks for your help

Janie xx
 
Upvote 0
Try the following;

Note: That The ontime method should be dismissed properly other wise it will run
again.....

In A Std Module<pre/>
Option Explicit
Public tTime

Sub UFrm_Show()
Load UserForm1
UserForm1.Show
End Sub

Sub ShowAfter()
Application.OnTime tTime, "UFrm_Show"
End Sub</pre>


In the UF Module;<pre/>
Private Sub CommandButton1_Click()

tTime = Now() + TimeSerial(0, 2, 0)
Application.OnTime tTime, procedure:="UFrm_Show"
Unload Me

End Sub

Private Sub UserForm_Initialize()
On Error Resume Next
Application.OnTime tTime, procedure:="ShowAfter", schedule:=False
On Error GoTo 0
End Sub</pre>



_________________
Kind Regards,<font size=+2><font color="red"> I<font color="blue">van<font color="red"> F M</font color="blue">oala</font><MARQUEE>Have a Nice day
sun.gif
</MARQUEE>
This message was edited by Ivan F Moala on 2002-05-09 03:02
 
Upvote 0
On 2002-05-09 03:00, buntykins wrote:

Thanks for all your help, so much for it being a very hard question!

Pfft, I didn't even bother replying, it was so trivial :wink:.
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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