A progress bar is used in a computer application to indicate the progress of an operation. It's commonly a rectangle that's animated as an operation makes progress. Visual Basic for Applications, or VBA, is a computer programming language used in Microsoft Office Applications to automate routine tasks and to create user interfaces. You can easily create a progress bar using VBA in Microsoft Office Excel. Excel is a spreadsheet application included in the Microsoft Office suite.
Open Microsoft Office Excel, then press "Alt" and "F11" to open the Visual Basic Editor. Right-click "VBAProject," then click "UserForm" to insert a new Form. From the "Toolbox" menu, click "Label." While holding your mouse button, drag on the Form to create a new label control.
Right-click the label and select "Properties," then change "Height" to 42 and "Width" to 12. Change the "Top" to 12. Create nine more labels using the same process.
Click "CommandButton" on the "Toolbox" pane and add a new button to your Form. Right-click "CommandButton" and click "View Code" to create a new procedure.
Video of the Day
Type the following to create a new variable and define its value:
Dim cnt As Integer cnt = 0
Type the following to hide all the labels when the Form starts:
Me.Label1.Visible = False Me.Label2.Visible = False Me.Label3.Visible = False Me.Label4.Visible = False Me.Label5.Visible = False Me.Label6.Visible = False Me.Label7.Visible = False Me.Label8.Visible = False Me.Label9.Visible = False Me.Label10.Visible = False
Type the following to create a while loop and iterate 10 times while pausing the code for 5 seconds:
Do While cnt <> 10
cnt = cnt + 1
Click the "Insert" menu then click "Module" to add a new module. Copy and paste the code below to start your "UserForm1.":
Sub showProgressBar() UserForm1.Show End Sub
Press "F5" to run your program.