I use this, it automatically calculates the progress bar:
Private Sub UserForm_Activate()
'User Form Code Module.
'You must make a userform with a progressBar on it!
'Note the progressbar is on "More Controls" [Right Click ToolBox].
Dim MyStart, MyDelay, MyFinish, CompletePct, MyCodeEndTest
'Sample code Defines.
Dim n As Integer
Dim MyCell As String
'Sample code Defines.
On Error GoTo MyEnd
MyCodeEndTest = False
n = 0
'Note: Timer in 100ths of a second.
MyStart = Timer
MyDelay = 5
MyFinish = MyStart + MyDelay
Do Until Timer > MyFinish
'This is part of the sample test code, you may not need this!
For a = 1 To 150000
'This is part of the sample test code, you may not need this!
CompletePct = (MyFinish - Timer) / MyDelay
Application.ScreenUpdating = True
UserForm1.ProgressBar1.Value = 100 - (CompletePct * 100)
'Your code to run with a "ProgressBar" go's here!
'Delete code between: This is sample...
'This is sample test code only!
Application.ScreenUpdating = False
n = n + 1
MyCell = "A" & n
Sheets("Sheet1").Select
Sheets("Sheet1").Range(MyCell).Select
Application.ScreenUpdating = True
Selection.Value = "Test"
Application.ScreenUpdating = False
Next a
'This is sample test code only!
'End your code with a "Done" test: MyCodeEndTest = True
MyCodeEndTest = True
If MyCodeEndTest = True Then GoTo MyEnd
Loop
MyEnd:
Unload UserForm1
'This is optional code!
Application.ScreenUpdating = True
MsgBox "Done!"
Sheets("Sheet1").Range("A:A").Value = ""
Sheets("Sheet1").Range("A1").Select
'This is optional code!
End Sub
Sub myXStart()
'Standard Module code like: Module1.
'This starts the ProgressBar user form that contains your code!
UserForm1.Show
End Sub