Hi,
I have a userform setup as a progressbar with lWidth being the total width of the bar.
The progressbar works when I put all of the code in the module. But this code is called about 50 times in my VBA and I would like to have the code in just one place. Can anyone advise on where I'm gonig wrong?
Thanks,
Knifey
‘Top of module:
Public Const lWidth As Long = 270
‘In loop:
frmProgressBar.LabelProgress.Width = lWidth * (xCount / xEndCount)
frmProgressBar.LabelText = Format(100 * (frmProgressBar.LabelProgress.Width / lWidth), "0") & " % Complete."
frmProgressBar.TextBox1.Text = "Proccessing " & xCount & " of " & xEndCount & " files."
DoEvents
‘Behind progressbar userform:
Option Explicit
Private Sub UserForm_Initialize()
Dim lWidth As Long
frmProgressBar.LabelText = ""
frmProgressBar.TextBox1.Text = ""
frmProgressBar.LabelProgress.Width = 0
lWidth = 270
Application.ScreenUpdating = True
DoEvents
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then Cancel = True
End Sub
Private Sub UserForm_Terminate()
Application.ScreenUpdating = False
End Sub
I have a userform setup as a progressbar with lWidth being the total width of the bar.
The progressbar works when I put all of the code in the module. But this code is called about 50 times in my VBA and I would like to have the code in just one place. Can anyone advise on where I'm gonig wrong?
Thanks,
Knifey
‘Top of module:
Public Const lWidth As Long = 270
‘In loop:
frmProgressBar.LabelProgress.Width = lWidth * (xCount / xEndCount)
frmProgressBar.LabelText = Format(100 * (frmProgressBar.LabelProgress.Width / lWidth), "0") & " % Complete."
frmProgressBar.TextBox1.Text = "Proccessing " & xCount & " of " & xEndCount & " files."
DoEvents
‘Behind progressbar userform:
Option Explicit
Private Sub UserForm_Initialize()
Dim lWidth As Long
frmProgressBar.LabelText = ""
frmProgressBar.TextBox1.Text = ""
frmProgressBar.LabelProgress.Width = 0
lWidth = 270
Application.ScreenUpdating = True
DoEvents
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then Cancel = True
End Sub
Private Sub UserForm_Terminate()
Application.ScreenUpdating = False
End Sub