Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Matt
 
Posts: n/a
Default Excel user defined functions.

I'd like to be able to define my own functions in Excel... for example: SPAN
could calculate the span of values in a selection (highest minus lowest) with
a single function rather than using MAX(C#R#:C#R#)-MIN(C#R#:C#R#) all the
time.
  #2   Report Post  
Jason Morin
 
Posts: n/a
Default

Try:

Function Span(rng As Range) As Double
With Application
Span = .Max(rng) - .Min(rng)
End With
End Function

---
HTH
Jason
Atlanta, GA

-----Original Message-----
I'd like to be able to define my own functions in

Excel... for example: SPAN
could calculate the span of values in a selection

(highest minus lowest) with
a single function rather than using MAX(C#R#:C#R#)-MIN

(C#R#:C#R#) all the
time.
.

  #3   Report Post  
KL
 
Posts: n/a
Default

Hi Matt,

Try putting this into a non-class module:

Function SPAN(rng As Range) As Double
With WorksheetFunction
SPAN = .Max(rng) - .Min(rng)
End With
End Function


Regards,
KL

"Matt" wrote in message
...
I'd like to be able to define my own functions in Excel... for example:
SPAN
could calculate the span of values in a selection (highest minus lowest)
with
a single function rather than using MAX(C#R#:C#R#)-MIN(C#R#:C#R#) all the
time.



  #4   Report Post  
Myrna Larson
 
Posts: n/a
Default

Be forewarned that if you implement that strategy for simple things like the
example you showed, your spreadsheets will be significantly slower to
calculate. Using your example on a range of 100 cells, the worksheet function
took 16 usecs, the VBA 24 usecs. That's a 50% difference.

To me, that speed penalty isn't worth it. IMO, you should use VBA only when
you can't accomplish the task with reasonable (i.e. understandable and
modifiable) worksheet formulas.

On Tue, 15 Mar 2005 08:55:02 -0800, "Matt"
wrote:

I'd like to be able to define my own functions in Excel... for example: SPAN
could calculate the span of values in a selection (highest minus lowest) with
a single function rather than using MAX(C#R#:C#R#)-MIN(C#R#:C#R#) all the
time.


  #5   Report Post  
Bernard Liengme
 
Posts: n/a
Default

It is so wonderful being retired and not having to wonder how to save 8
microseconds!
Just think if the program did this 1000 times, it would take 1/60th of a
minute longer to run.
--
Bernard V Liengme
www.stfx.ca/people/bliengme
remove caps from email

"Myrna Larson" wrote in message
...
Be forewarned that if you implement that strategy for simple things like
the
example you showed, your spreadsheets will be significantly slower to
calculate. Using your example on a range of 100 cells, the worksheet
function
took 16 usecs, the VBA 24 usecs. That's a 50% difference.

To me, that speed penalty isn't worth it. IMO, you should use VBA only
when
you can't accomplish the task with reasonable (i.e. understandable and
modifiable) worksheet formulas.

On Tue, 15 Mar 2005 08:55:02 -0800, "Matt"

wrote:

I'd like to be able to define my own functions in Excel... for example:
SPAN
could calculate the span of values in a selection (highest minus lowest)
with
a single function rather than using MAX(C#R#:C#R#)-MIN(C#R#:C#R#) all the
time.




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
In excel how do I protect the format of a cell but let the user c. John Louis Excel Discussion (Misc queries) 11 October 1st 07 12:03 AM
user defined function row number bj Excel Worksheet Functions 11 March 9th 05 01:31 PM
Excel user management CTE Excel Discussion (Misc queries) 1 February 22nd 05 12:12 PM
Columns in Excel will not allow user to click in them Kim Excel Discussion (Misc queries) 1 December 28th 04 06:37 PM
how would i change default user name all excel files learner Excel Discussion (Misc queries) 1 November 29th 04 10:12 PM


All times are GMT +1. The time now is 07:03 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"