VBA userform progress bar variant problem

  • Thread starter Thread starter Legacy 395409
  • Start date Start date
L

Legacy 395409

Guest
For the life of me I cannot figure out what am I missing....

1650515284946.png
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Please don't bump your own post after only 30 minutes.

You need to declare total as Integer in the Inert_Copied_Rows routine.
 
Upvote 0
Sorry about that.

I tried declare total as integer but still error...

1650589557243.png


It kept getting error from this line..

Call RunStatusBar(Rows, Total)

What else am I missing?
 
Upvote 0
Got an update.... I changed to current code and it allows me to run the macro but the progress bar keeps showing only 0% the bar didnt move at all even after the whole operation has completed. So now I know at least the function works, just the userform's progress bar didnt get the right values to show. Anybody knows what went wrong for the progress bar part?

VBA Code:
'-----------------------------------------------------------
Sub Inert_Copied_Rows()
  
OpenStatusBar

Worksheets("1149000-00-A").Activate

Dim Total As Integer
Dim Row As Integer

Dim r As Long
    For r = Range("A" & Rows.Count).End(xlUp).Row To 1 Step -1
        With Cells(r, 3)
            If IsNumeric(.Value) And Not IsEmpty(.Value) Then
                Rows(r + 1).Resize(.Value).Insert
                Range(Replace("A#:AK#", "#", r)).Copy Destination:=Range("A" & r + 1).Resize(.Value)
            End If
    
    DoEvents
    Call RunStatusBar(Row, Total)
    
    End With
Next r

Unload StatusBar

MsgBox "All Needed Rows Added!"

End Sub
'-----------------------------------------------------------
Sub OpenStatusBar()

With StatusBar
    .Bar.Width = 0
    .Frame.Caption = "0% Complete"
    .Show vbModeless
End With
End Sub
'-----------------------------------------------------------
Sub RunStatusBar(Row As Integer, Total As Integer)

With StatusBar
    .Bar.Width = 288 * (Row / Rows.Count)
    .Frame.Caption = Round((Row / Rows.Count) * 100, 0) & "% Complete"
End With
End Sub
'-----------------------------------------------------------
 
Upvote 0
How many rows are you dealing with? Given that there are over a million rows in a sheet, Round((Row / Rows.Count) * 100, 0) will remain 0 until you hit around 5250
 
Upvote 0
Hi Rory, thx for reply. My sheet has around 28000 rows of data & around A-AK columns.
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top