Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Replacement for Dsum - calling countif from aVBA

A common problem I find is that the very useful D* worksheet functions
require two rows in order to specify their ctiteria. This is fine
until you want to put on on every line in a big report.

For years I've put up with this, but recently decided to write my own
funciton in VBA with a nicer criteria specifiction model (one which
uses at most one line).

In order to provide a rich set of test operators (and also to keep
consistency with the D* functions) I have written my function to
actually use worksheetfunction.countif() to do the actual comparison.

My function merrily goes down the input range using countif to select
cells, then I do with them what I will and return a result.

So far, so good.

Except for very large datasets it all goes a bit slowly.

Now - to the question:

One standard way to get VBA functiuons which operate on a large dataset
to run quiker is to assign the range to a variant (array) at first, and
then use the array. This cuts out he continual spreadsheet conversion.

BUT

worksheetfunction.countif() requires a range as its input parameter.

Anybody got any clever ideas?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default Replacement for Dsum - calling countif from aVBA

My rule of thumb says its usually faster to either use a range variable and
never transfer the data to VBA at all, or transfer to VBA and do all the
processing on the transferred array.

But you can always do both: if you define the input parameter as a range you
can then reference it as a range object.
Then you can also assign the range object to a variant variable containing
an array to get the data when you want to process it as an array.

It would probably be faster if you rewrote your use of COUNTIF in VBA to
work against the array and avoided worksheet functions.


regards
Charles
______________________
Decision Models
FastExcel 2.3 now available
Name Manager 4.0 now available
www.DecisionModels.com

"Peter" wrote in message
ups.com...
A common problem I find is that the very useful D* worksheet functions
require two rows in order to specify their ctiteria. This is fine
until you want to put on on every line in a big report.

For years I've put up with this, but recently decided to write my own
funciton in VBA with a nicer criteria specifiction model (one which
uses at most one line).

In order to provide a rich set of test operators (and also to keep
consistency with the D* functions) I have written my function to
actually use worksheetfunction.countif() to do the actual comparison.

My function merrily goes down the input range using countif to select
cells, then I do with them what I will and return a result.

So far, so good.

Except for very large datasets it all goes a bit slowly.

Now - to the question:

One standard way to get VBA functions which operate on a large dataset
to run quiker is to assign the range to a variant (array) at first, and
then use the array. This cuts out he continual spreadsheet conversion.

BUT

worksheetfunction.countif() requires a range as its input parameter.

Anybody got any clever ideas?



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
#N/A Replacement Susana C via OfficeKB.com Excel Discussion (Misc queries) 2 December 29th 06 05:06 PM
DDE Replacement? Mark Excel Programming 1 September 10th 06 05:30 AM
Replacement T De Villiers[_47_] Excel Programming 0 July 21st 06 03:53 PM
Replacement T De Villiers[_48_] Excel Programming 0 July 21st 06 03:53 PM
Replacement T De Villiers[_46_] Excel Programming 0 July 21st 06 03:53 PM


All times are GMT +1. The time now is 09:11 PM.

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

About Us

"It's about Microsoft Excel"