You should reduce the frequency of DoEvents calls. For example if your code executes in a loop then you should call DoEvents, for example once in 1000 iterations, like this.
___
...
For ... ' Start of the loop that does the process
...
'At the end of the loop
Dim Count As Integer
Count = Count + 1
If Count = 1000 Then
Count = 0
DoEvents 'Called once in 1000 iterations.
End If
Next
___
You should also not call the Refresh method of any object (like form or button). When you call a DoEvents, all objects are repainted and refreshed. An additional call to refresh will only waste the time.
Moreover, you should not update the progress bar value during each iteration of the loop. Progress bar should be updated only when it needs to be updated. (i.e. when the new calculated value is different from its current value.)
When you assign a new value to the progress bar's Value property, it is repainted completely even if the new value is same as its current value.
So it is advised to store the current value of the status bar in a variable (0 to 100), calculate the new value, if it is different from the last one stored in the variable, then only assign this new value to progress bar and also update the last value stored in the variable.
Place two command buttons and a progress bar on the form and paste the following code and run the program. You will understand what I mean to say.
___
Private Sub Command1_Click()
Dim N As Long
For N = 1 To 1000000 'Always update the progress bar
ProgressBar1.Value = N / 10000
Next
End Sub
Private Sub Command2_Click()
Dim N As Long, Value As Long, LastValue As Long
For N = 1 To 1000000
Value = N / 10000
If LastValue <> Value Then 'Update only when needed
LastValue = Value
ProgressBar1.Value = Value
End If
Next
End Sub