Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Slow Calculating and optimizing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kurt - 26 Sep 2007 11:48 GMT
Hi

I have been using the expression =SUMPRODUCT(--(file'!$P$1:$P
$65500="txt");'file'!$H$1:$H$65500)
to summarize all cells in column H where column P= "txt"

I have 1200 of theese expressions and it make the startup and
recalculating very slow (3-4 minutes)

The 65500 is choosed to be sure that I never ran out of Data and it
was not based on an analyze.

To optimize this cut the 65500  down to a relevant size ( ex. 10000)
and then the calculation time is reduced dramatically.

regards

Kurt
Roger Govier - 26 Sep 2007 12:05 GMT
Hi Kurt

Try creating dynamic ranges for your data
For example
Insert>name>define> Name    colP  Refers to =OFFSET($P$1,0,0,COUNTA($P:$P))

Repeat for colH

Then use
=SUMPRODUCT(--(colP=".txt");--(ColH))

To ensure that all of your ranges have the same length, use COUNTA($P:$P) in
all cases, or whichever column will not have any blank data within it

I usually prefer to have one named variable  lrow  where I would set it as
=COUNTA($P:$P)
Then all the other named ranges would be, for example
=OFFSET($P$1,0,0,lrow)

Signature

Regards
Roger Govier

> Hi
>
[quoted text clipped - 14 lines]
>
> Kurt
Tom Ogilvy - 26 Sep 2007 12:32 GMT
While Roger gives good advice for dynamic ranges, in this case, you don't
need to us sumproduct at all.  Since you only have one condition, the much,
much faster

=Sumif('file'!P:P,"txt",'File'!H:H)

would work fast and doesn't restrict your range.

If 'file" will be closed, then Sumif does not work against a closed workbook
and you would have to go with Sumproduct and perhaps use Roger's suggestion.  

Signature

Regards,
Tom Ogilvy

> Hi Kurt
>
[quoted text clipped - 33 lines]
> >
> > Kurt
Jim Thomlinson - 26 Sep 2007 17:00 GMT
There is a trade off to be had if you use the dynamic named range in that
offset is a volatile function. That means that all 1,200 functions become
volatile and while they will calculate faster they will also calculate more
often. This strategy could work for you or against you depending on the time
savings. If it does not work out then you might want to consider using some
code to redefine the range names when then overall number of rows of source
data increases or decreases.
Signature

HTH...

Jim Thomlinson

> Hi Kurt
>
[quoted text clipped - 33 lines]
> >
> > Kurt
Roger Govier - 26 Sep 2007 20:16 GMT
Hi

Whilst I agree entirely with Tom's advice to the OP about SUMIF, and that
this would speed up the calculations far more, and with your point about
volatility using OFFSET, I thought after posting, I should have offered the
OP INDEX instead as a non-volatile solution.
I went out immediately after posting and have only just returned.

Again define lrow as per my previous posting  =COUNTA($P:$P)
Then use the following for the column name colP
=$P$1:INDEX($P:$P,lrow)

Signature

Regards
Roger Govier

> There is a trade off to be had if you use the dynamic named range in that
> offset is a volatile function. That means that all 1,200 functions become
[quoted text clipped - 48 lines]
>> >
>> > Kurt
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.