PDA

View Full Version : Hide ProgressBar After Process Loop Is Complete



k0st4din
04-23-2014, 09:26 AM
Hello to all
I asked in another forum but did not get a response to my inquiry and therefore want to ask you if you can help me. It's an "ProgressBar" which is placed in several macro but performs the same action in a "UserForm"
Colleague helped me to implement , but we could not deal with the problem - when you complete your action to hide this "ProgressBar"
Shows a macro ( as the others are similar ) and show what I've tried must complete it to hide it "ProgressBar", but obviously wrong somewhere and I hide all "UserForm".
I would be grateful if we can find a solution or tell me what I must complete .

Private Sub CommandButton2_Click()
Dim x As Long, Cell As Range, CellText As String, ws As Worksheet, lTotalRows As Long
Dim Words As Variant, Replacements As Variant
Const TableSheetName As String = "Sheet1"
Application.Volatile
Words = Sheets(TableSheetName).Range("AH2", Sheets(TableSheetName).Cells(Rows.Count, "AH").End(xlUp))
Replacements = Sheets(TableSheetName).Range("AI2", Sheets(TableSheetName).Cells(Rows.Count, "AI").End(xlUp))
For Each ws In Worksheets
lTotalRows = ws.Range("J2", ws.Cells(Rows.Count, "J").End(xlUp)).Rows.Count
For Each Cell In ws.Range("J2", ws.Cells(Rows.Count, "J").End(xlUp))
ProgressBar1.Value = Int(100 * (Cell.Row - 1) / lTotalRows)
DoEvents
CellText = ""
For x = 1 To UBound(Words)
If InStr(1, Cell.Value, Words(x, 1), vbTextCompare) Then CellText = CellText & "+" & Replacements(x, 1)
Next
Cell.Offset(, 4).Value = Mid(CellText, 2)
Next
Next
ProgressBar1.Value = 100
End
Unload ProgressBar1 'I Ended this and it works, but it hides all the UserForm, which brings me to the conclusion that something has to inquire, but I do not know what.
End Sub

Excel Fox
04-23-2014, 04:35 PM
Try
ProgressBar1.Visible = False

k0st4din
04-23-2014, 08:38 PM
Hello, thanks a lot, but again not working and again hides all "UserForm"
If we could try something else?

Excel Fox
04-23-2014, 09:21 PM
Just noticed that you are using this line in your code
EndWhy would you ever use the End statement in your code. Please remove and try again.

k0st4din
04-24-2014, 12:29 AM
Yes yes yes now works without problem.
Many thanks from me to you.
And with regard to this "End" - I wrote it because I myself do not know how to do it and tried different options and it did not work and I was desperate.
Once again thank you warmly. :hug: