Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Convert function to sub

I know this may sound odd, but I was wondering if there
was a user defined function equivalent to the following
array formula:

={AVERAGE(IF((DateRange=A1)*
(DateRange<=A2),StockPrice,FALSE))}

What this does is look up the dates in 'DateRange' that
fall between the dates entered into cells 'A1' and 'A2',
and then takes the average of the prices from the
range 'StockPrice'.

Thanks for any help.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Convert function to sub

Hi
why do you want a UDF for this. This would surely been slower?

--
Regards
Frank Kabel
Frankfurt, Germany

"Craig" schrieb im Newsbeitrag
...
I know this may sound odd, but I was wondering if there
was a user defined function equivalent to the following
array formula:

={AVERAGE(IF((DateRange=A1)*
(DateRange<=A2),StockPrice,FALSE))}

What this does is look up the dates in 'DateRange' that
fall between the dates entered into cells 'A1' and 'A2',
and then takes the average of the prices from the
range 'StockPrice'.

Thanks for any help.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Convert function to sub

You're right. I guess I'm curious if it's at all possible
to put any type of array formula like this into a module -
but I see your point - why bother.

Thanks

-----Original Message-----
Hi
why do you want a UDF for this. This would surely been

slower?

--
Regards
Frank Kabel
Frankfurt, Germany

"Craig" schrieb im

Newsbeitrag
...
I know this may sound odd, but I was wondering if there
was a user defined function equivalent to the following
array formula:

={AVERAGE(IF((DateRange=A1)*
(DateRange<=A2),StockPrice,FALSE))}

What this does is look up the dates in 'DateRange' that
fall between the dates entered into cells 'A1' and 'A2',
and then takes the average of the prices from the
range 'StockPrice'.

Thanks for any help.


.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Convert function to sub

FYI it's possible to convert it into a User Defined Formula.
If you're still interested, let us know for examples.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Craig" wrote in message
...
You're right. I guess I'm curious if it's at all possible
to put any type of array formula like this into a module -
but I see your point - why bother.

Thanks

-----Original Message-----
Hi
why do you want a UDF for this. This would surely been

slower?

--
Regards
Frank Kabel
Frankfurt, Germany

"Craig" schrieb im

Newsbeitrag
...
I know this may sound odd, but I was wondering if there
was a user defined function equivalent to the following
array formula:

={AVERAGE(IF((DateRange=A1)*
(DateRange<=A2),StockPrice,FALSE))}

What this does is look up the dates in 'DateRange' that
fall between the dates entered into cells 'A1' and 'A2',
and then takes the average of the prices from the
range 'StockPrice'.

Thanks for any help.


.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Convert function to sub

In answer to your curiosity, you have two choices.

The brute-force approach would be to iterate through all of the cells in
DateRange and check for being in the range, and average the corresponding
values in StockPrice.

The second would be to call the worksheetfunction from within the VBA.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Craig" wrote in message
...
You're right. I guess I'm curious if it's at all possible
to put any type of array formula like this into a module -
but I see your point - why bother.

Thanks

-----Original Message-----
Hi
why do you want a UDF for this. This would surely been

slower?

--
Regards
Frank Kabel
Frankfurt, Germany

"Craig" schrieb im

Newsbeitrag
...
I know this may sound odd, but I was wondering if there
was a user defined function equivalent to the following
array formula:

={AVERAGE(IF((DateRange=A1)*
(DateRange<=A2),StockPrice,FALSE))}

What this does is look up the dates in 'DateRange' that
fall between the dates entered into cells 'A1' and 'A2',
and then takes the average of the prices from the
range 'StockPrice'.

Thanks for any help.


.





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
can the "convert" function in excel convert to UK gallons? JR Excel Discussion (Misc queries) 2 April 24th 08 04:55 PM
Convert function to value JC Excel Discussion (Misc queries) 1 March 28th 07 02:35 AM
Convert function to value Max Excel Discussion (Misc queries) 0 March 28th 07 12:20 AM
Convert Function jayceejay New Users to Excel 3 October 18th 06 03:42 AM
Convert function D Excel Worksheet Functions 2 January 5th 06 05:53 PM


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

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"