Solved

Store results in memory instead of each time writing results in sheet(cell).

Posted on 2012-12-27
3
156 Views
Last Modified: 2013-01-11
Dear,

I'm including some accuracy control mechanism in a simulation Tool I build to re-rate made mobile calls.

The tool has a "control modus". If selected, the result (in this case the duration of the call ) is written in the current selected row offset by 18 colums.

When rerating +100K rows, and even with screenupdating and calc disabled, it runs very slow.

Is there a possibility to keep results in the memory (array), and only write the result once, once all rerating has been done.

Select Case ControlModus
    Case Is = "YES", "Yes", "yes"
        ActiveCell.Offset(0, 18).Value = CdrSeconds ' uncomment this in case you want to write control figures next to CDR's
    Case Else
End Select

Open in new window


Thank you for your help
/Xtophe
0
Comment
Question by:Xtophe_S
3 Comments
 
LVL 20

Accepted Solution

by:
clarkscott earned 250 total points
ID: 38723465
Well... putting values on spreadsheet is, virtually, maintaining values in an array (since these values are in memory).   With +100k rows... and understanding how Excel maintains row data in memory... you're probably better off using the spreadsheet method versus memory arrays.  

But, depending on how you use this data in your application... you may want to write your data to a sheet like a table (1st row contains headers, all other rows contain data) and access your data on the sheet by opening it like a table and query your data using SQL type statements.

Scott C
0
 
LVL 85

Assisted Solution

by:Rory Archibald
Rory Archibald earned 250 total points
ID: 38723505
Writing 100k cells one by one will be very very slow, so yes you would be far better off writing the results to an array and then writing that to the sheet in one go using a simple:
Range("Y1").Resize(ubound(myarray, 1), ubound(myarray, 2)).Value = myArray

Open in new window


syntax
0
 
LVL 14

Expert Comment

by:Faustulus
ID: 38726144
Have you considered setting Application.ScreenUpdating = False?
The effect would be that no time is spent on updating your screen. Hence, all data are kept in arrays managed by Excel which, arguably, should not be slower than using arrays managed by the user.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Dealing with unintended Excel Active-X resizing quirks (VBA code simulates "self correction") David Miller (dlmille) Intro Not everyone is a fan of Active-X controls in spreadsheets (as opposed to the UserForm approach, the older Form controls …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now