Solved

Using a progress bar while running a routine

Posted on 2011-03-10
6
767 Views
Last Modified: 2012-08-14
I have done some research in the Knowledgebase and found a number of articles on progress bars such as the link below.  I am having trouble figuring out how to call a routine and have a progress bar display while the macro performs such as the prgress bar that is in the link below.  I have a macro that creates a csv file, saves this to a specified folder, then logs into a secure ftp server and saves the file on the server, then ends the routine.  The process takes approximately 20 seconds, however this could vary depending on internet connection speeds.  So I am really looking for a progress bar that will actually track the progress of the macro, if this is possible.

http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_1756-A-VBA-Progress-Bar-for-Excel-and-Other-Microsoft-Apps.html?sfQueryTermInfo=1+10+30+excel+progressbar+vba

ID 1756
0
Comment
Question by:jlove88
6 Comments
 
LVL 23

Accepted Solution

by:
Michael74 earned 125 total points
ID: 35099759
The example provided relies on you setting the minimum and maximum values. In fact all progress bars rely on a coded guess as to how long the code will run. If you do not want to use an educated guess then you could just use the status bar to show that code is running and then a messagebox to indicate that the code has completed.

Michael
0
 
LVL 22

Assisted Solution

by:rspahitz
rspahitz earned 125 total points
ID: 35099761
Although there are some progress bar controls available for other things, there's nothing built in for Excel so you'll have to make your own (or load one from outside, which may require installing it if you share the workbook.)

What comes to mind is to open a UserForm with a simple label in it.  Inside the label you can add little pieces of text that represent the progress (like capital "i" or ".")
Every time you hit a certain point in the macro, you simply add another character to the label.
when you're done, you close the form from code.

Ideally, you will know how many times you'll hit the piece of code (like with a For/Next counter) or some other way to calculate the number of iterations so that you can put the right number of characters to fill the label when it completes.

Do you want to give this a try?
0
 
LVL 42

Assisted Solution

by:dlmille
dlmille earned 125 total points
ID: 35099911
I use the status bar for my progress.  If I have a loop I'm working through, I can determine % complete.

Inside the loop, say every 20 or 100 loops, I update the statusbar...

e.g.,

 
Sub testwStatusBar()
Dim i As Double

    For i = 0 To 500000
     If i Mod 1000 = 0 Then
        Application.StatusBar = "Running... -> " & Format(i / 500000, "0.00%") & " complete..."
     End If
    Next i
    
    Application.StatusBar = False

End Sub

Open in new window


Dave
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 45

Assisted Solution

by:patrickab
patrickab earned 125 total points
ID: 35115588
use the Status BAr to let you kno how th macro is progressing. it \doesn't interfere so much as a progress bar.

Patrick
0
 

Author Closing Comment

by:jlove88
ID: 35192484
All comments were useful however after playing around with the ideas, I decided not to use a progress bar.  I think it fair to divide the points equally and thank you for responding.
0
 
LVL 45

Expert Comment

by:patrickab
ID: 35193725
Points' divide is fine. A progress bar i good eye candy but thats' about all. stick with the Status bar and make it informative- that'll help a lot more
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question