Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Status Bar Every Nth Loop

I just put a status bar within a loop. When I run it with the status
bar it takes 1 minute and 55 seconds. When I comment out the statusbar
logic it takes 6 seconds. I didn't realize how much memory the status
bar takes within large loops(10,000X244). Is there a way to only run
the status bar every nth loop?


AMax = 10000
BMax = 244
ReDim DataArray(1 To AMax, 1 To BMax)
StartTime = Now()
For A = 1 To AMax
For B = 1 To BMax
Randomize
RandomVar = Rnd()
DataArray(A, B) = RandomVar
Application.StatusBar = "Filling VBA Array " & (A * BMax -
(BMax - B)) / (AMax * BMax) * 100 & "%."
Next B
Next A


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Status Bar Every Nth Loop

A very simple way would be to put the status bar update outside the B loop,
but within the A loop. Reduces the number or writes by 244.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"ExcelMonkey " wrote in message
...
I just put a status bar within a loop. When I run it with the status
bar it takes 1 minute and 55 seconds. When I comment out the statusbar
logic it takes 6 seconds. I didn't realize how much memory the status
bar takes within large loops(10,000X244). Is there a way to only run
the status bar every nth loop?


AMax = 10000
BMax = 244
ReDim DataArray(1 To AMax, 1 To BMax)
StartTime = Now()
For A = 1 To AMax
For B = 1 To BMax
Randomize
RandomVar = Rnd()
DataArray(A, B) = RandomVar
Application.StatusBar = "Filling VBA Array " & (A * BMax -
(BMax - B)) / (AMax * BMax) * 100 & "%."
Next B
Next A


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Status Bar Every Nth Loop

one way to dispaly on every 10th loop

if left(b,1)="0" then
Application.StatusBar = "Filling VBA Array " & (A * BMax - (BMax - B))
/ (AMax * BMax) * 100 & "%."
end if

you could also use select case statement


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Status Bar Every Nth Loop

ExcelMonkey

You could try something like this to limit the number of times you update
the Status Bar

If A Mod 100 = 1 Then
Application.StatusBar = "Filling VBA Array " & _
(A * BMax - (BMax - B)) / (AMax * BMax) * 100 & "%."
End If

Regards

Trevor


"ExcelMonkey " wrote in message
...
I just put a status bar within a loop. When I run it with the status
bar it takes 1 minute and 55 seconds. When I comment out the statusbar
logic it takes 6 seconds. I didn't realize how much memory the status
bar takes within large loops(10,000X244). Is there a way to only run
the status bar every nth loop?


AMax = 10000
BMax = 244
ReDim DataArray(1 To AMax, 1 To BMax)
StartTime = Now()
For A = 1 To AMax
For B = 1 To BMax
Randomize
RandomVar = Rnd()
DataArray(A, B) = RandomVar
Application.StatusBar = "Filling VBA Array " & (A * BMax -
(BMax - B)) / (AMax * BMax) * 100 & "%."
Next B
Next A


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
reuest formula for auto update status & status date PERANISH Excel Worksheet Functions 5 June 2nd 08 04:26 PM
How about the status bar? Default User Excel Discussion (Misc queries) 1 March 11th 05 08:49 AM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 03:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"