Data
Found a function to do 1 criteria but I need to find a Function that can use 2 criteria. Need to have min or max of Criteria 1 = Column J and Criteria 2 = Column E Giving me the result from Column H(Min)/I(Max).
I need to do this in a VBA. I will be changing the Start date in column H to the Min on the code and changing the End Date Max on the code to Max.
So for code 177591 and group link 123, Min = 2/2/25 and Max =2/22/25
Sub JUNK2()
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
MyMin = minMax(Range("E2:E" & LastRow), "max")
End Sub
Function minMax(ByVal rRange As Range, MinOrMax As String) As Double
Dim dMin As Double
Dim dMax As Double
Dim lLastRow As Long
Dim ws1 As Worksheet
Set ws1 = ActiveWorkbook.ActiveSheet
lLastRow = ws1.Cells(rRange.Row, rRange.Column).End(xlDown).Row
dMin = ws1.Cells(rRange.Row, rRange.Column).Value
dMax = dMin
For Each Cell In rRange.Cells
If Cell.Value < dMin Then dMin = Cell.Value
If Cell.Value > dMax Then dMax = Cell.Value
Next Cell
If InStr(1, MinOrMax, "min") = 1 Then
minMax = dMin
Else
minMax = dMax
End If
End Function
Found a function to do 1 criteria but I need to find a Function that can use 2 criteria. Need to have min or max of Criteria 1 = Column J and Criteria 2 = Column E Giving me the result from Column H(Min)/I(Max).
I need to do this in a VBA. I will be changing the Start date in column H to the Min on the code and changing the End Date Max on the code to Max.
So for code 177591 and group link 123, Min = 2/2/25 and Max =2/22/25
Sub JUNK2()
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
MyMin = minMax(Range("E2:E" & LastRow), "max")
End Sub
Function minMax(ByVal rRange As Range, MinOrMax As String) As Double
Dim dMin As Double
Dim dMax As Double
Dim lLastRow As Long
Dim ws1 As Worksheet
Set ws1 = ActiveWorkbook.ActiveSheet
lLastRow = ws1.Cells(rRange.Row, rRange.Column).End(xlDown).Row
dMin = ws1.Cells(rRange.Row, rRange.Column).Value
dMax = dMin
For Each Cell In rRange.Cells
If Cell.Value < dMin Then dMin = Cell.Value
If Cell.Value > dMax Then dMax = Cell.Value
Next Cell
If InStr(1, MinOrMax, "min") = 1 Then
minMax = dMin
Else
minMax = dMax
End If
End Function