![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: Apr 2002
Posts: 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 |
|
|
|
|
|
#2 |
|
MrExcel MVP
Join Date: Mar 2002
Location: Kobe, Japan
Posts: 1,420
|
Hi. Why dont't you use flag?
|
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
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 |
|
|
|
|
|
#4 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
|
Try the following;
Note: That The ontime method should be dismissed properly other wise it will run again..... In A Std Module Option Explicit Public tTime Sub UFrm_Show() Load UserForm1 UserForm1.Show End Sub Sub ShowAfter() Application.OnTime tTime, "UFrm_Show" End Sub In the UF Module; 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 _________________ Kind Regards, Ivan F Moala [ This Message was edited by: Ivan F Moala on 2002-05-09 03:02 ] |
|
|
|
|
|
#5 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
Thanks for all your help, so much for it being a very hard question! |
|
|
|
|
|
#6 | |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
Quote:
|
|
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
He he, sure Mudface, sure... Maybe you should change your name to Egg-On-Face xx |
|
|
|
|
|
#8 | |
|
New Member
Join Date: May 2002
Posts: 1
|
Quote:
|
|
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2002
Posts: 76
|
LOL!! I concede |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|