Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 287
Default Min IF Function Needed

I am looking for a function that is a lot like SUMIF function but is Min if.
Returns the min in a range by criteria.
Range, Criteria, and Min range
Any help would be great. Example below for what I am needing and below that
is code I found on this forum from Steve. I use it and get #value.
Thanks in advance!

PN |QTY| Min (Needed)
123 | 4 | 2
123 | 5 | 2
123 | 6 | 2
568 | 8 | 8
568 | 9 | 8
238 | 5 | 5
238 | 6 | 5
123 | 2 | 2

Public Function MinIf(Ref_Range As Range, Criterion As Variant, Min_Range As
Range) As Single
Dim cell As Range
Dim minVal As Single
Dim iRow As Integer, jCol As Integer, iCount As Integer, jCount As
Integer

iCount = Ref_Range.Rows.Count
jCount = Ref_Range.Columns.Count

minVal = Application.WorksheetFunction.Max(Min_Range)

For iRow = 1 To iCount
For jCol = 1 To jCount
If Ref_Range.Cells(iRow, jCol).Value = Criterion Then
If Min_Range.Cells(iRow, jCol).Value < minVal Then
minVal = Min_Range.Cells(iRow, jCol).Value
End If
End If
Next
Next

MinIf = minVal


End Function

Aaron


Reply
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
Function needed fgwiii[_2_] Excel Worksheet Functions 3 September 16th 08 04:28 PM
IF THEN function help needed!! Karen Excel Worksheet Functions 2 July 6th 06 09:55 PM
Function needed???? prbucci Excel Worksheet Functions 9 January 15th 06 07:26 AM
Function needed please Stadinx Excel Worksheet Functions 1 April 20th 05 07:49 AM
Help Needed With - If-Function Adrian Jones Excel Worksheet Functions 1 November 6th 04 08:57 PM


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