Progress bar & explanation of code

M

M1kehailu

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
 
J

Jim Cone

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"
<[email protected]>
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top