View Full Version : Solved: VBA , min of 2 nox , >0
nitzbar
08-06-2008, 03:43 PM
Hi .. i need to write a function that returns the smaller of 2 nos as long as the smaller one is less than zero, else it returns the larger one..
mikerickson
08-06-2008, 04:33 PM
=IF(MIN(A1,A2)<0,MIN(A1,A2),MAX(A1,A2))
Bob Phillips
08-07-2008, 12:45 AM
Function myNum(rng1 As Variant, rng2 As Variant)
Dim tmp1 As Double
Dim tmp2 As Double
tmp1 = rng1: tmp2 = rng2
If tmp1 > rng2 Then tmp1 = rng2: tmp2 = rng1
If tmp1 >= 0 Then
myNum = tmp2
Else
myNum = tmp1
End If
End Function
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.