The Main subroutine populates cells with random numbers. The procedure that is attached to the Activate event of the user form calls the Main subroutine. The ShowUserForm subroutine shows the user form. The progress bar increases as the Main subroutine populates the cells on the worksheet. In the Macro dialog box, click to select ShowUserForm, and then click Run.Ī dialog box that has a red progress bar appears.
In Excel 2007, click Macros in the Code group on the Developer tab. In Excel 2003 and in earlier versions of Excel, point to Macro on the Tools menu, and then click Macros. ' The DoEvents allows the UserForm to update. FrameProgress.Caption = Format(PctDone, "0%")
' Update the Caption property of the Frame control. ' The task is finished, so unload the UserForm. ' Call subroutine that updates the progress bar. In the Code window for the module, type the following code: Sub ShowUserForm() ' Set the width of the progress bar to 0. In the module, type the following code for the UserForm_Activate event: Private Sub UserForm_Activate() Note If the Properties window is not visible, click Properties Window on the View menu.Ĭhange the following properties of the Frame control to the following values:ĭraw a Label control on the Frame control.ĭouble-click the user form to open the Code window for the user form.
This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. Microsoft provides programming examples for illustration only, without warranty either expressed or implied.
This article describes how to create a progress bar with a user form in Microsoft Excel.
If you have a Microsoft Visual Basic for Applications macro that takes a long time to finish, you may want to give the user an indication that the macro is progressing correctly.