Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Craig Daniels   on Jan 03 In MS Office Category.

  
Question Answered By: Damon Perez   on Jan 03

To utilize a progress  meter control you need to add a 'User Form'. You
would then need to call the form whenever the macro/program is executed.
A 'User Form' will have standard controls available, but the 'Progress
Meter' tool may need to be added. Simply right mouse click the controls
that appear next to the user form, and select  'Additional Controls'.
Scroll down until you see 'Microsoft Progress Meter'. There may be more
than one version, I always use the most recent version.



Insert the control on your user form, and give it a logical name, along
with your user form. Now it is time for code.



Here is a procedure that calculates a percentage of completion and
updates the progress meter control.



Sub IncreaseBar(iCurVal As Integer, iMaxVal As Integer)



Dim Percent As String

Dim PercentLabel As String

Dim sMaxVal As String

Dim sCurVal As String



'Put integers into strings

sMaxVal = iMaxVal

sCurVal = iCurVal

'Increase progress bar

Percent = getPercentage(sCurVal, sMaxVal)

Forms!frmMain!EmpProgressBar.Value = Percent 'Make sure to use your
form name, and name of control!!

DoEvents



End Sub



Function getPercentage(ProgressBarCurrentValue As String,
ProgressBarMaxValue As String) As String

'calculate Percentage

getPercentage = Format(Val(Val(ProgressBarCurrentValue /
ProgressBarMaxValue) * 100), "0")

End Function



As you can see in the main sub procedure, you need to bring in the total
rows being calculated, and the current row position being worked on. You
can alter this any way you like, such as calculating number of rows etc.
within the procedure. My code is a secondary sub procedure as I port
this to all my programs where I use a progress meter. I have many, and
the users like to see it.

Share: 

 

This Question has 8 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Progress Bar and Browse window in Excel macro Or get search suggestion and latest updates.


Tagged: