Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Excel Genii,
I've Created MaxIf and MinIf functions analogous to SumIf. But it's not clear to me how to insert the Condition string captured in the dialog box into the IF block in the functions themselves in order to check each value in the selected range. Any ideas? Thanks, Steve |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Below is a simple form of the function. It doesn't cover the case where the
criteria may be a range of cells, but does show how to break the condition into multiple parts. Function maxif(Target As Range, criteria As String) If InStr(criteria, "<") 0 Then Value1 = Left(criteria, InStr(criteria, "<") - 1) If InStr(criteria, "=") 0 Then Condition = "<=" Value2 = Mid(criteria, InStr(criteria, "=") + 1) Else Condition = "<" Value2 = Mid(criteria, InStr(criteria, "<") + 1) End If Else If InStr(criteria, "") 0 Then Value1 = Left(criteria, InStr(criteria, "") - 1) If InStr(criteria, "=") 0 Then Condition = "=" Value2 = Mid(criteria, InStr(criteria, "=") + 1) Else Condition = "" Value2 = Mid(criteria, InStr(criteria, "") + 1) End If Else 'must be just an equal sign Value1 = Left(criteria, InStr(criteria, "=") - 1) Value2 = Mid(criteria, InStr(criteria, "=") + 1) Condition = "" End If If Not IsNumeric(Value1) Then Value1 = Range(Value1) End If If Not IsNumeric(Value2) Then Value2 = Range(Value2) End If Select Case Condition Case "" Truth = Value1 Value2 Case "=" Truth = Value1 = Value2 Case "<" Truth = Value1 < Value2 Case "<=" Truth = Value1 <= Value2 Case "=" Truth = (Value1 = Value2) End Select End Function "SteveM" wrote: Excel Genii, I've Created MaxIf and MinIf functions analogous to SumIf. But it's not clear to me how to insert the Condition string captured in the dialog box into the IF block in the functions themselves in order to check each value in the selected range. Any ideas? Thanks, Steve |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Question about a new equation or function I am unfimiliar with | Excel Discussion (Misc queries) | |||
equation / function question | Excel Worksheet Functions | |||
Excel "Insert Formula" dialog always call my user defined function | Excel Programming | |||
User define function and dialog | Excel Programming | |||
User function argument question | Excel Programming |