I want to write a reuseable maxif function in vba. The following code 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 commonly available. I tried it with the following code but it doesn't work. I assume there is a problem with the passing of the range parameters. I also tried it with String and Variant as parameter types - without success. Can anybody help me?