Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 968
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default 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




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
example using DSUM worksheet function in a VBA function excelman Excel Programming 3 February 9th 06 05:28 PM
WorkSheet Function Help Ron Coderre Excel Worksheet Functions 0 February 6th 06 09:31 PM
Reference the worksheet from a multiple worksheet range function ( DBickel Excel Worksheet Functions 1 May 28th 05 03:49 AM
Can the offset worksheet function reference another worksheet AlistairJ Excel Worksheet Functions 2 May 9th 05 06:18 PM
formula/function to copy from worksheet to worksheet Jen Excel Programming 5 January 11th 05 08:22 PM


All times are GMT +1. The time now is 12:45 PM.

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

About Us

"It's about Microsoft Excel"