run the macro based on timer counter on userform for specific time

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
397
Office Version
  1. 2016
Platform
  1. Windows
hello

I search for procedure before run the macro . so if I press button to run the macro ,then pops up message " you should wait at this time PM 21:12:00" and if I choose OK then should show timer counter on userform to see how remained time to PM 21:12:00 and if reached for this time , then should run the macro, if it's past then shouldn't work , keep timer counter to see how remained time and if press NO shouldn't show the userform and exit .
thanks
 
It was not easy to understand problem and find right way
I appreciate it even if my problem is not solved.
unfortunately doesn't work . I use F8 may be gives error or something but the code finish in this line
without pass in others lines .
and where is the procedure of my macro should add it
VBA Code:
    MsgBox "This is your macro"
to run if matched with the time , is it end of the code in modula standard ?
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Set the first line of code to time greater then currently time. (vTime = "21:12:00").
You have ask for this time, so this is time when you want macro to run.
Your final macro can be called in the end of this procedure.
VBA Code:
    Do While vClose = False
        DoEvents
    Loop
    UserForm1.Hide
    vClose = False
    'call your macro here
    
End Sub
 
Upvote 0
finally it works but there is problem when close the userform it run the macro . it shouldn't be.
 
Upvote 0
Yes, you are right.
Let's try to change finish to look like this.
VBA Code:
    Do While vClose = False
        DoEvents
    Loop
    If UserForm1.Label1.Caption = "00:00:01" Then
        UserForm1.Label1.Caption = ""
        UserForm1.Hide
        'call your macro here
    End If
    vClose = False

End Sub
 
Upvote 0
thanks again , but doesn't work . it still runs the macro when close the form
 
Upvote 0
It can't be.
The macro will run only if Label1 caption is "00:00:01".
Check that. Put message box before last "If" statement and see what is the label caption.
 
Upvote 0
Put message box before last "If" statement and see what is the label caption
my apologies ! I don't read well when you added comment inside the code where put the macro .

now it works greatly ! many thanks for every thing (y)
 
Upvote 0
Thanks God, I was afraid we don't understand each other.
I'm glad now works fine. Thanks for feedback.;)
 
Upvote 0

Forum statistics

Threads
1,215,455
Messages
6,124,936
Members
449,195
Latest member
Stevenciu

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