ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Progress bar & explanation of code (https://www.excelbanter.com/excel-programming/424959-progress-bar-explanation-code.html)

M1kehailu

Progress bar & explanation of code
 
Hello again, I've found some code on the net which is exactly what I need bar
a progress bar. But I've tried and failed in including one in this
example....Is there a way? I got confused because the counter variable is
already being manipulated...and can anyone explain why nothing has been
declared? I have the whole file for anyone who is interested.

Many thanks in advance

M1keHailu

Do While Not IsEmpty(Sheets("return").Cells(1, colr))
colx = getcolumnofselectedcompany(Sheets("return").Cells( 1, colr))
tot = 0
Counter = 0
Application.ScreenUpdating = False

If OptLogRet.Value = True Then
rowx = 3
Do While Not IsEmpty(Sheets("Return").Cells(rowx, 1))
Sheets("Return").Cells(rowx, colr) =
(Log(Sheets("portfolio").Cells(rowx + 1, colx)) -
Log(Sheets("portfolio").Cells(rowx, colx)))
tot = tot + Sheets("Return").Cells(rowx, colr)
Counter = Counter + 1
rowx = rowx + 1
Loop
End If

If OptSimRet.Value = True Then
rowx = 3
Do While Not IsEmpty(Sheets("Return").Cells(rowx, 1))
Sheets("Return").Cells(rowx, colr) =
(Sheets("portfolio").Cells(rowx + 1, colx) - Sheets("portfolio").Cells(rowx,
colx)) / Sheets("portfolio").Cells(rowx, colx)
tot = tot + Sheets("Return").Cells(rowx, colr)
Counter = Counter + 1
rowx = rowx + 1
Loop
End If
Columns(colr).AutoFit

Sheets("Return").Cells(398, colr).Value = tot / Counter

colr = colr + 1
Loop
Application.ScreenUpdating = True




Jim Cone[_2_]

Progress bar & explanation of code
 
It appears you are updating a worksheet cell.
It so, you must have ScreenUpdating set to True while the code is running.
--
Jim Cone
Portland, Oregon USA



"M1kehailu"

wrote in message
Hello again, I've found some code on the net which is exactly what I need bar
a progress bar. But I've tried and failed in including one in this
example....Is there a way? I got confused because the counter variable is
already being manipulated...and can anyone explain why nothing has been
declared? I have the whole file for anyone who is interested.
Many thanks in advance
M1keHailu

Do While Not IsEmpty(Sheets("return").Cells(1, colr))
colx = getcolumnofselectedcompany(Sheets("return").Cells( 1, colr))
tot = 0
Counter = 0
Application.ScreenUpdating = False

If OptLogRet.Value = True Then
rowx = 3
Do While Not IsEmpty(Sheets("Return").Cells(rowx, 1))
Sheets("Return").Cells(rowx, colr) =
(Log(Sheets("portfolio").Cells(rowx + 1, colx)) -
Log(Sheets("portfolio").Cells(rowx, colx)))
tot = tot + Sheets("Return").Cells(rowx, colr)
Counter = Counter + 1
rowx = rowx + 1
Loop
End If

If OptSimRet.Value = True Then
rowx = 3
Do While Not IsEmpty(Sheets("Return").Cells(rowx, 1))
Sheets("Return").Cells(rowx, colr) =
(Sheets("portfolio").Cells(rowx + 1, colx) - Sheets("portfolio").Cells(rowx,
colx)) / Sheets("portfolio").Cells(rowx, colx)
tot = tot + Sheets("Return").Cells(rowx, colr)
Counter = Counter + 1
rowx = rowx + 1
Loop
End If
Columns(colr).AutoFit

Sheets("Return").Cells(398, colr).Value = tot / Counter
colr = colr + 1
Loop
Application.ScreenUpdating = True


All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com