Sub UpdateProgressBar(n As Long, m As Long, Optional DisplayText As String)
'// DarkSprout April08
'// Omit DisplayText to display progress percentage
On Error GoTo ERR_HANDLE
If n >= m Then
ProgressBar.Hide
Else
If ProgressBar.Visible = False Then ProgressBar.Show
ProgressBar![BoxProgress].Caption = IIf(DisplayText = "", Round(((n / m) * 10000) / 100) & "%", DisplayText)
ProgressBar![BoxProgress].Width = (n / m) * 468
DoEvents
End If
Exit Sub
ERR_HANDLE:
Err.Clear
ProgressBar.Hide
End Sub
Sub test()
Dim x As Long
For x = 1 To 100
UpdateProgressBar x, 100
Next x
End Sub