Help to get Label.Caption each row on 5 second

sbv1986

Board Regular
Joined
Nov 2, 2017
Messages
87
This code belove will take random cells text to Label1.Caption in Form

Now i want Lebel1.Caption will appear Cells(1,4) 5 seconds then cells(2,4) 5 seconds then cells(3,4) 5 seconds .... to the end row.
Please help me to do that, thanks in advance./.

Code:
[COLOR=#141414][FONT=inherit]Private Sub Userform_Initialize()[/FONT][/COLOR]<code style="box-sizing: border-box; font-family: inherit; font-size: 1em;">   Label1.Caption = ThisWorkbook.Sheets("data").Cells(WorksheetFunction.RandBetween(1, 200), 4).Text </code>[COLOR=#141414][FONT=inherit]End Sub[/FONT][/COLOR]
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
To observe the changes must be in the activate event


Code:
Private Sub [COLOR=#0000ff]UserForm_Activate[/COLOR]()
    i = 1
    For i = 1 To 5
        Label1.Caption = Sheets("data").Cells(i, 4).Value
        Application.Wait Now + TimeValue("00:00:05")
        DoEvents
    Next
    MsgBox "Welcome"
End Sub
 
Upvote 0
Thanks code work but there has a problem that time still running to the end of row(i), but I want when I close Form with "Unload Me" this Events will stop.
 
Upvote 0
Use this

Press unload and wait for the 5 seconds to end and the form will close.

Code:
Dim xClose


Private Sub UserForm_Activate()
    i = 1
    For i = 1 To 5
        If xClose = 0 Then End
        Label1.Caption = Sheets("data").Cells(i, 4).Value
        Application.Wait Now + TimeValue("00:00:05")
        DoEvents
    Next
    MsgBox "Welcome"
End Sub


Private Sub Userform_Initialize()
    xClose = 1
End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
    xClose = CloseMode
    End
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,880
Messages
6,175,152
Members
452,615
Latest member
bogeys2birdies

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