ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   xll worksheet function (https://www.excelbanter.com/excel-programming/359007-xll-worksheet-function.html)

RB Smissaert

xll worksheet function
 
Been playing with UDF's in .xll add-ins and found that these are indeed much
faster than VBA UDF's.
In a moderately complex math function I found it about 30 times faster.

Just one thing I don't quite understand:
I have the xll function in B1 and the VBA function in C1
Now I copy both down to row 65536.
All cells in column B are calculatated in about 1 second,
except cell B1, which is done last. This is done after the last cell in
column C is done.
Swapping the columns (XLL in C and VBA in B) makes no difference.

Any suggestions why this and if anything can be done about it?

RBS


Charles Williams

xll worksheet function
 
Excel's default calculation sequence is to calculate the last cell entered
first (LIFO) and so on.

Note that VBA functions calculate much slower in Automatic mode than when in
manual and calculation is initiated from VBA (this is a VBE refresh bug).
see http://www.DecisionModels.com/Calcsecretsj.htm

It would be very interesting to get a timing comparison in manual using
Application.calculate.

Charles Williams
Decision Models

"RB Smissaert" wrote in message
...
Been playing with UDF's in .xll add-ins and found that these are indeed
much faster than VBA UDF's.
In a moderately complex math function I found it about 30 times faster.

Just one thing I don't quite understand:
I have the xll function in B1 and the VBA function in C1
Now I copy both down to row 65536.
All cells in column B are calculatated in about 1 second,
except cell B1, which is done last. This is done after the last cell in
column C is done.
Swapping the columns (XLL in C and VBA in B) makes no difference.

Any suggestions why this and if anything can be done about it?

RBS




RB Smissaert

xll worksheet function
 
Yes, LIFO explained that one.

And indeed doing Application.Calculate is much faster indeed.
For the VBA UDF I had timings of about 25 seconds versus 5 seconds.
I hadn't been using UDF's in my app until a few weeks ago and I wasn't aware
of this.

So maybe I should do something like this:

Sub test()

Dim xlCalcMode As XlCalculation

With Application

'to retain the user's setting
xlCalcMode = .Calculation

.Calculation = xlManual

'run code

.Calculate

'return to the user's setting
.Calculation = xlCalcMode

End With

End Sub


RBS


"Charles Williams" wrote in message
...
Excel's default calculation sequence is to calculate the last cell entered
first (LIFO) and so on.

Note that VBA functions calculate much slower in Automatic mode than when
in manual and calculation is initiated from VBA (this is a VBE refresh
bug).
see http://www.DecisionModels.com/Calcsecretsj.htm

It would be very interesting to get a timing comparison in manual using
Application.calculate.

Charles Williams
Decision Models

"RB Smissaert" wrote in message
...
Been playing with UDF's in .xll add-ins and found that these are indeed
much faster than VBA UDF's.
In a moderately complex math function I found it about 30 times faster.

Just one thing I don't quite understand:
I have the xll function in B1 and the VBA function in C1
Now I copy both down to row 65536.
All cells in column B are calculatated in about 1 second,
except cell B1, which is done last. This is done after the last cell in
column C is done.
Swapping the columns (XLL in C and VBA in B) makes no difference.

Any suggestions why this and if anything can be done about it?

RBS






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com