Userform: Clear Label Captions after X Seconds

JumboCactuar

Well-known Member
Joined
Nov 16, 2016
Messages
785
Office Version
  1. 365
Platform
  1. Windows
Hi,
I have a macro assigned to a button on Userform which places certain data in Labels 1-5

I want these label captions to automatically clear after 5 seconds OR when macro is run again

What is best way to do this?

Thanks in advance
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
We probable need more details.

So like is this Label1 and label2 and label3 and label4 and Label5
These are considered default names
And you want all the labels cleared as the last step in your macro.
Is that correct.



Waiting 5 seconds may be more then I can do.

Why not show us your code your running and we can add a new line of code to your code.
 
Upvote 0
We probable need more details.

So like is this Label1 and label2 and label3 and label4 and Label5
These are considered default names
And you want all the labels cleared as the last step in your macro.
Is that correct.



Waiting 5 seconds may be more then I can do.

Why not show us your code your running and we can add a new line of code to your code.

I can later when I get to PC but I think the code is irrelevant to what I need.

I basically have a macro assigned to button in Userform (this runs an SQL query and outputs the result in different labels.)
E.g Label1.Caption="Example Output"

I want to (after the macro is finished) clear the label after a set time

I know I can somehow use application.ontime to schedule the clear
 
Upvote 0
Try this:

In your userform:
VBA Code:
Private Sub CommandButton1_Click()
  Label1.Caption = "Hello"
  Label2.Caption = "Bye"
  Application.OnTime Now + TimeValue("00:00:05"), "ClearLabels"
End Sub

In a Module:
VBA Code:
Sub ClearLabels()
  UserForm1.Label1.Caption = ""
  UserForm1.Label2.Caption = ""
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,213,522
Messages
6,114,112
Members
448,549
Latest member
brianhfield

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