View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Amedee Van Gasse Amedee Van Gasse is offline
external usenet poster
 
Posts: 49
Default speeding up calculation: replacing array formula with databasefunction?

On 7 apr, 19:15, Charles Williams wrote:
Assuming you data is sorted (or can be sorted) on column A and starts
in Row 2 then you don't need array formulas:


Your assumption is correct. The data is (or can be) sorted: column A
ascending, column B descending.
One problem: the data in B isn't always numerical. Sometimes it is the
text "N/A", and that gets sorted before the numbers.
I will have to add a bit of code to the import function, to replace "N/
A" (or any non-numerical text) with the value 0.
Something like

shDAT.Cells(NewRow, 2).Value = Val(cvsf.getItem(i).Version)

so that Val("Kilmer") = 0.


in column C (or somewhere suitable) add a helper column containing
=IF(A2<A1,COUNTIF(A:A,"="&A2),0)
and fill down
in Column D put
=IF(C20,MAX(OFFSET(B2,0,0,C2,1)),D1)
and fill down

If you can Sort Ascending on Column A and Descending on Column B
then you would just need this formula (filled down) in D
=IF(A2<A1,B2,D1)


Meh. I should have thought of that. KISS.
Thanks Charles. Calculation is now several magnitudes faster.
I still have to clock the time increase because of implementing the
Val() function, but I can't imagine that it will add a lot.

--
Amedee