PDA

View Full Version : Solved: Minimum Positive value finder using VBA



Olxa123
04-05-2009, 08:09 AM
Could you help me to find MINIMUM Positive value in VBA. I tried to cope with this problem but nothing worked for me.
I've found just MINIMUM (without consideration of positive values)...

Here is the attached file (.xls)

Thank You in advance

P.S. I would be very grateful, if you could answer as soon as possible!

Zack Barresse
04-05-2009, 08:46 AM
Hi, welcome to the board!

If you're looking for the minimum y value greater than zero, use this array formula, confirmed with Ctrl + Shift + Enter...
=MIN(IF(B14:B114>0,B14:B114))
Excel will put the curly brackets { } around your formula, they are not put in by hand (you).

HTH

Bob Phillips
04-05-2009, 09:08 AM
In VBA, that would be



Dim LastRow As Long
Dim MinValue As Double

With ActiveSheet

LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row
MinValue = .Evaluate("MIN(IF(B2:B" & LastRow & ">0,B2:B" & LastRow & "))")
End With

Zack Barresse
04-05-2009, 09:11 AM
"in VBA"... kind of a key point.. :whistle: