LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default maxif function in vba


Hi
I want to write a reuseable maxif function in vba. The following cod
is working when entered directly into the cell:

=SUMPRODUCT(MAX((B1:B6=B2) * (A1:A6)))

Now I want to pack this function into vba code to make it commonl
available. I tried it with the following code but it doesn't work.
assume there is a problem with the passing of the range parameters.
also tried it with String and Variant as parameter types - withou
success. Can anybody help me?

Public Function MaxIF(criteriaRange As Range, searchValue As Variant
calcRange As Range)

AciveCell.Formula = "=SumProduct(Max((criteriaRange = searchValue
* (calcRange)))"

End Functio

--
mien
-----------------------------------------------------------------------
mienz's Profile: http://www.excelforum.com/member.php...fo&userid=1630
View this thread: http://www.excelforum.com/showthread.php?threadid=27697

 
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
Maxif ShaneDevenshire Excel Discussion (Misc queries) 0 October 17th 08 09:08 PM
MAXIF style function CindyC Excel Worksheet Functions 7 October 16th 08 04:00 AM
Looking for the equivalent of a Maxif function PerplexedinKY Excel Discussion (Misc queries) 6 January 20th 07 03:57 AM
"MAXIF" Equivalent function in Excel Vital Miranda Excel Worksheet Functions 5 September 27th 06 11:56 PM
maxif Gregg Excel Worksheet Functions 4 December 29th 04 12:52 AM


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