0 votes
in VBA by Expert (916 points)

Hello everyone


In the following code, it is supoosed to get the label caption updated by time 1,2,...5

Sub Test()
    Dim i As Integer

    UserForm1.Show vbModeless
    For i = 1 To 5
        UserForm1.Label1.Caption = "status message " & i
        Application.Wait Now() + TimeValue("00:00:01")
    Next i
    Unload UserForm1
End Sub

But when loading the form, I can just see status message 1 and nothing else till the end

How can this be updated so as to get the status message 2 and status message 3 and so on..

1 Answer

0 votes
by Expert (916 points)
selected by
Best answer

I have found a solution using this line after Label1.Caption


And I welcome any other solutions if there are any ones.

by Super Expert (3.2k points)

Using Repaint is the appropriate way to do this. I use it often on UserForms with dynamic content. Here are a couple examples:

by Expert (916 points)
Thank you very much Mr. Ryan

Welcome to wellsr Q&A
Ask any questions you have about VBA and Python and our community will help answer them. wellsr Q&A is the standalone question and answer platform for wellsr.com. If you have a question about one of our specific tutorials, please include a link back to the tutorial.

Getting Started
VBA Cheat Sheets (On Sale Now)

Looking for something else? Hire our team directly through ourVBA Help page, instead.

For more programming tips visit the VBA Tutorials Blog and the Python Tutorials Blog.