我正在使用进度条向用户显示正在运行的宏的状态,但是因为宏删除了行,所以它向后运行For i = lastrow To 2 Step -1
,这意味着我的进度条从100%运行到2 %。Excel VBA反向进度条
我只有计算了i
,是否有可能使倒数时向后读取信息,所以对用户来说,它显然是在计数?
Sub update()
Dim lastRow As Integer, email As String, pctCompl As Single
lastRow = Sheets("Sheet1").Range("C5000").End(xlUp).Row
For i = lastRow To 2 Step -1
email = Trim(Cells(i, 3).Value)
Set c = Sheets("Sheet3").Range("A:A").Find(email, LookIn:=xlValues)
If Not c Is Nothing Then
Cells(i, 1).EntireRow.Delete
End If
pctCompl = i
progress pctCompl
Next i
End Sub
Sub progress(pctCompl As Single)
UserForm1.Text.Caption = pctCompl & "% Completed"
UserForm1.Bar.Width = pctCompl * 2
DoEvents
End Sub
好了十分感谢,我没想到这个,但我现在得到“364%完成”(或最后一行数)。 –
好点 - 我没有想过这个。我更新了代码来计算百分比。 –