简体   繁体   English

Excel VBA 进度/状态栏

[英]Excel VBA Progress/Status Bar

today i try to learn vba progress bar/status bar, i put below code in vba code and want to diplay status bar while calling two macros, but i's not working, there is no error, msgbox 'done' appeared, two macros supposed to run also not executed;今天我尝试学习 vba 进度条/状态栏,我将下面的代码放在 vba 代码中,想在调用两个宏时显示状态栏,但我不工作,没有错误,出现 msgbox 'done',两个宏应该运行也没有执行; anyone know what goes wrong with the code?有谁知道代码出了什么问题? Thank you.谢谢你。

Sub LOOP_GENERATEREPORT()
Dim I As Integer
Dim loopRng As RANGE
Dim r As RANGE

'----progress bar
Dim x As Integer
Dim MyTimer As Double
'------/progress bar

Application.ScreenUpdating = False

Sheet10.Activate
   y = Sheet10.RANGE("a24").Value
     For I = 1 To lastRow

'---------progress bar
Application.StatusBar = False
'----------/progress bar


For Each r In Sheet10.RANGE("a26", RANGE("a" & Rows.Count).End(xlUp))
    Sheet2.RANGE("ae8").Value = r.Value
Set loopRng = Worksheets("setting").RANGE("a24")

ActiveWindow.ScrollRow = loopRng
Application.CutCopyMode = False

Application.DisplayAlerts = True
Application.ScreenUpdating = False

' ---------progress bar
Application.StatusBar = "SMART Report printing in progress, please wait..." & I & " of " & y + 0 & " or " & Format((I - 1) / y, "0.00%") & "."

Call convertformula
Call CopySummaryRow44

Next r
Next I

'---------progress bar
Application.StatusBar = True
'----------/progress bar

Sheet2.Activate
MsgBox "DONE"
Sheet2.RANGE("ae8").Select

End Sub

The False in Application.StatusBar = False is wrong: you should provide strings, egFalseApplication.StatusBar = False是错误的:你应该提供的字符串,如

Application.StatusBar = "False" ' to display "False"

or或者

Application.StatusBar = "" ' to cancel

etc.等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM