PDA

View Full Version : Progress Bar



gssrsuba
03-02-2012, 07:22 AM
Hello All

Could you please someone help me

I have macro, it is running sucessfully, it is just like formating data.

Depepending data size, its takking time to complete.

I need to show the user progressbar to % of done.

Could you please some provide the code to done.

regards
Ramu

Paul_Hossler
03-02-2012, 09:37 AM
Simple way to do it

Paul

gssrsuba
03-03-2012, 01:00 AM
Hello

Could you please some one help me

I need to shows the progress bar to user while running my macro. I dont know the timing of completion as depends upon the data size. sometime 10 sec, some 15 minues to 30 min. It has to fetch data from server and then it process the data. Depending server speed, it takes time to running the macro.

Could you please some one proivde the macro code for above requirement

Regards
Ramu

Paul_Hossler
03-03-2012, 06:32 AM
1. look at the sample I sent. It WILL require you to customize it for each situation.

2. To calculate the percent complete in order to show a progress bar you need to know:
a. How many there are in total
b. The current number of items that have been processes


If you do not know the total number of items, then I'd suggest using the StatusBar and just put out a message

In my sample macro in the workbook I just used 100,000 as the total item count, and the value of i in the 'For i = 1 to 100,000' loop as the current iteration number

The percent and therefore how full the progress bar is is equal to i / 100,000
So if there are 54,321 records and you're processing record number 23,456 then the percent complete is 23,456 / 54,321 or 43% and the progressbar would be 43% filled

I attempted to try and use your 'read from a server' requriement with the fictional example below.

If you're interested in trying the code I posted, you WILL need to integrate it into your application, especially the initialization and the update calls


Public Sub ReadDataFromServer
Dim iNumberOfRecordsTotal As Long, iNumberOfRecordsRead As Long
'initialize the message and the total number of records
Call Progress_Init("Now reading data", iNumberOfRecords)

iNumberOfRecordsRead = 0

Open file

Do While Not EOF

Read a record

iNumberOfRecordsRead = iNumberOfRecordsRead + 1

'update progress bar
Progress_Number (iNumberOfRecordsRead)

Loop

Close file

'remove progress bar
Progress_Done

End Sub


Paul