copyt
04-27-2012, 04:13 AM
Hello all, could you please help me to correct my code? The progress bar doesn't stop at 100%.
Option Explicit
Sub Batchcalculation()
Application.ScreenUpdating = False
Dim finalrow As Long, _
i As Long
Dim PctDone As Single
Dim Counter As Integer
Worksheets("XLanalyzer").Activate
Counter = 1
finalrow = Cells(Rows.Count, 5).End(xlUp).Row
Worksheets("XLanalyzer").Cells(7, 5).Select
For i = 7 To finalrow
If Cells(i, 5) <> "" And Sheets("RawMS").Cells(4, 1) <> "" Then
Cells(i, 5).Activate
Worksheets("XLanalyzer").Range("G7:j10000").ClearContents
Worksheets("XLanalyzer").Range("G7").Value = ActiveCell.Value
Call MSMSRawData
Counter = Counter + 1
Else
MsgBox "Please upload MS data", vbCritical, "XLanalyzer Warning"
End If
PctDone = 2 * Counter / (finalrow)
With UserForm2
.FrameProgress.Caption = Format(PctDone, "0%")
.LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
End With
DoEvents
Next i
Unload UserForm2
MsgBox "Done"
UserForm1.Show vbModeless
End Sub
PS It would be great if you could also explain a bit about the correction.
Any help would be appreciated. :bow:
Option Explicit
Sub Batchcalculation()
Application.ScreenUpdating = False
Dim finalrow As Long, _
i As Long
Dim PctDone As Single
Dim Counter As Integer
Worksheets("XLanalyzer").Activate
Counter = 1
finalrow = Cells(Rows.Count, 5).End(xlUp).Row
Worksheets("XLanalyzer").Cells(7, 5).Select
For i = 7 To finalrow
If Cells(i, 5) <> "" And Sheets("RawMS").Cells(4, 1) <> "" Then
Cells(i, 5).Activate
Worksheets("XLanalyzer").Range("G7:j10000").ClearContents
Worksheets("XLanalyzer").Range("G7").Value = ActiveCell.Value
Call MSMSRawData
Counter = Counter + 1
Else
MsgBox "Please upload MS data", vbCritical, "XLanalyzer Warning"
End If
PctDone = 2 * Counter / (finalrow)
With UserForm2
.FrameProgress.Caption = Format(PctDone, "0%")
.LabelProgress.Width = PctDone * (.FrameProgress.Width - 10)
End With
DoEvents
Next i
Unload UserForm2
MsgBox "Done"
UserForm1.Show vbModeless
End Sub
PS It would be great if you could also explain a bit about the correction.
Any help would be appreciated. :bow: