Solved

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

Posted on 2012-12-27
3
165 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 …
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

914 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

12 Experts available now in Live!

Get 1:1 Help Now