Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,533
- Office Version
- 365
- 2016
- Platform
- Windows
I need to get the min and max values of the series of rows where the value in column C = "textvalue"
What I attempted, was to apply a filter to the data to isolate those rows in which column C = "textvalue". I then created the formulae to determine the min value from column P, and max value from column P.
Turns out, I got the min and max values of the entire database ... not the isolated rows. How can I determine (VBA) the min and max values of only those select rows.
What I attempted, was to apply a filter to the data to isolate those rows in which column C = "textvalue". I then created the formulae to determine the min value from column P, and max value from column P.
Turns out, I got the min and max values of the entire database ... not the isolated rows. How can I determine (VBA) the min and max values of only those select rows.
Code:
Sub Wroxeter()
Dim wshcore As Worksheet
Set wshcore = Worksheets("CONTROL_1")
'Excelsior
With wshcore
llastrow = wshcore.Range("A" & Rows.Count).End(xlUp).Row
.AutoFilterMode = False
.Range("A1:EH" & llastrow).AutoFilter
.Range("A1:EH" & llastrow).AutoFilter Field:=8, Criteria1:="TextValue"
lwmin = Application.Min(.Range("N:N"))
lwmax = Application.Max(.Range("O:O"))
MsgBox "Excelsior" & Chr(13) & " Minimum: " & Format(lwmin, "h:mm AM/PM") & Chr(13) & " Maximum: " & Format(lwmax, "h:mm AM/PM")
End With
End Sub
Last edited: