Skip to content

Update README.md #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions Event_ProgressBar.bas

This file was deleted.

53 changes: 0 additions & 53 deletions Form Setup ReadMe.txt

This file was deleted.

Binary file removed Progress Bar.xlsm
Binary file not shown.
135 changes: 135 additions & 0 deletions ProgressExamples.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
Attribute VB_Name = "ProgressExamples"
Public Sub example()
' example()
' no parameters
' Provides a time based example for the ProgressForm

Dim i As Long

' Displays the ProgressForm and initializes it
ProgressForm.start

'simply a loop to do something for showing the ProgressForm
For i = 0 To 100 Step 6
' Updates the % on the ProgressForm
ProgressForm.update i

Application.Wait (Now + TimeValue("0:00:01"))
Next

' hides the ProfessForm and cleans up
ProgressForm.done
End Sub


Public Sub example2()
' example2()
' no parameters
' Provides a time based example for the ProgressForm with a different Caption

Dim i As Long

' Displays the ProgressForm and initializes it
ProgressForm.start ("Are we done yet?")

For i = 0 To 100 Step 6
ProgressForm.update i
Application.Wait (Now + TimeValue("0:00:01"))
Next
ProgressForm.done
End Sub


Public Sub example3()
' example3()
' no parameters
' Provides a time based example for the ProgressForm with macro interruption

Dim i As Long

' Displays the ProgressForm and initializes it
Call ProgressForm.start(, True)

' or any of the following
'ProgressForm.start , True
'ProgressForm.start "With Interrupt", True
'ProgressForm.start bInterrupt:=True


For i = 0 To 100 Step 6
ProgressForm.update i
Application.Wait (Now + TimeValue("0:00:01"))
Next
ProgressForm.done
End Sub


Public Sub example4()
' example4()
' no parameters
' Provides a time based example using a label with the progress

Dim i As Long
ProgressForm.start

For i = 0 To 5
' Updates the % on the ProgressForm with a label
ProgressForm.update (i / 5 * 100), "Performing Task: " & i

Application.Wait (Now + TimeValue("0:00:01"))
Next

' hides the ProfessForm and cleans up
ProgressForm.done
End Sub



'finally an example that does something useful
Public Sub clearBlankCells()
' clearBlankCells
' parameters: none are provided, but uses Selection to specify the range of cells to clear
' if selection is a single cell, the entire active range is used
' Removes blank cells (cells that are empty) and blank rows (rows that have no non-empty cells)
'
Dim r As Range ' area to manipulate
Dim i As Long, j As Long ' indicies
Dim x As Long, y As Long ' dimensions
Dim isBlank As Boolean ' blank row text


Set r = Selection
If (r.rows.Count = 1 And r.columns.Count = 1) Then
Set r = Range(Range("A1"), Range("A1").SpecialCells(xlCellTypeLastCell))
End If

x = r.rows.Count
y = r.columns.Count

Set r = r(1)

' Displays the ProgressForm and initializes it
ProgressForm.start

For i = x - 1 To 0 Step -1
isBlank = True
For j = y - 1 To 0 Step -1
If (IsEmpty(r.Offset(i, j))) Then
r.Offset(i, j).Delete (xlToLeft)
Else
isBlank = False
End If
Next
If isBlank Then
r.Offset(i, y).EntireRow.Delete
End If

' Updates the % on the ProfressForm
ProgressForm.update CLng((x - i) / x * 100)

Next

' hides the ProfessForm and cleans up
ProgressForm.done

End Sub
37 changes: 29 additions & 8 deletions ProgressForm.frm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} ProgressForm
Caption = "Progress Indicator"
ClientHeight = 1080
Caption = "Progress"
ClientHeight = 1995
ClientLeft = 120
ClientTop = 465
ClientWidth = 4395
Expand All @@ -13,14 +13,35 @@ Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub UserForm_Activate()
Call SampleEventStatusGenerator
Unload ProgressForm
Option Explicit

Private Sub InterruptButton_Click()
Application.SendKeys "^{BREAK}"
End Sub

Private Sub UserForm_Initialize()
ProgressForm.Status.Caption = "0% Complete"
ProgressForm.Bar.Width = 10
End Sub


Private Sub UserForm_Initialize()
ProgressForm.Status.Caption = "0% Complete"
ProgressForm.Bar.Width = 10
Sub start(Optional strCaption As String = "Progress", Optional bInterrupt As Boolean = False)
InterruptButton.Visible = bInterrupt
ProgressForm.Caption = strCaption
ProgressForm.Show (0)
End Sub


Sub update(lngPercentComplete As Long, Optional strStatus As String = "")

ProgressForm.Bar.Width = 2 * lngPercentComplete
ProgressForm.Status.Caption = lngPercentComplete & "% Complete"

SubStatus.Caption = strStatus
DoEvents
End Sub

Sub done()
Unload ProgressForm
End Sub

Binary file modified ProgressForm.frx
Binary file not shown.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# ExcelVBA_ProgressBar
Launches a customizable userform that displays as an animated progress bar dependent upon a percent complete status.
Creates a simple non-modal dialog in Excel
Used to effectively show the progress of a macro

## Installation
1) Download
2) In Excel VBA Editor:
+ File -> Import File ...
+ Select ProgressForm.frm
+ Optionally, repeat for ProgressExamples.bas

## Usage
```
Sub example()
ProgressForm.start # displays the ProgressForm
ProgressForm.update pct # updates the ProgressForm to pct%
ProgressForm.done # hides the ProgressForm
End Sub
```

## License
GNU Public License