-1

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; 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
robin
  • 171
  • 1
  • 6
  • 23
  • Would be helpful to know what the current result is? Are you getting any error messages? Consider editing your question using the guidance here: https://stackoverflow.com/help/how-to-ask – QHarr Oct 07 '17 at 10:02
  • after i run the macro msgbox 'done' appeared. what is going on? – robin Oct 07 '17 at 10:19
  • tq for ur guidance, i amended my question. – robin Oct 07 '17 at 10:20
  • Indent you code properly. You can use the the the RubberDuck COM add-in for this. See here: http://rubberduckvba.com/ Avoid using .Select see here https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba. Fully qualify things you are referencing e.g. ThisWokbook.Sheets("Sheet10"). Declare the variable y as Long and place Option Explicit at the top of the module so any typos are picked up. Those are some immediate thoughts. – QHarr Oct 07 '17 at 10:37
  • make sure you have Application.DisplayStatusBar = True and put this after Application.ScreenUpdating = False. Get rid of the line where you have set it to False as it will not then show. – QHarr Oct 07 '17 at 11:07
  • single-step the code using F8. that should tell you the sequence of events in the code. – jsotola Oct 08 '17 at 07:06

1 Answers1

0

The False in Application.StatusBar = False is wrong: you should provide strings, e.g.

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

or

Application.StatusBar = "" ' to cancel

etc.