user4572896
user4572896

Reputation: 141

MIN IF Function in VBA

I would like to create a code in VBA which does the same function as those:

{=MIN(IF(rng1=criteria1,IF(rng2=criteria2,values)))}

and

{=MAX(IF(rng1=criteria1,IF(rng2=criteria2,values)))}

I have a lot of those function calls in document and it works really slow so I want to replace that...

Basically the result is to find a criteria in row and then in other range find minimum(higher than 0) and maximum value.

Do you have any ideas? Thank you in advance.

Upvotes: 0

Views: 6941

Answers (1)

Lowpar
Lowpar

Reputation: 907

Sheets("Name").Range("A1").FormulaArray = "=MIN(IF(sheet1!C:C=""A"",sheet!E:E))"

where column C is the range with the criterion and column E contains the values where you would like to extract the min.

Upvotes: 1

Related Questions