View Single Post
 
Old 04-07-2018, 03:28 PM
NoSparks NoSparks is offline Windows 7 64bit Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Hello dan

Think you're going to need VBA for this.

If you filter your data for =505 then use something along the lines of the code below
you could calculate everything except your TimeB.

This assumes .areas(1) is just the header row and starts doing its thing at areas(2),
not ideal but maybe it will give you some ideas.
Code:
With filtRng.Columns(2).SpecialCells(xlCellTypeVisible)
    For i = 2 To .Areas.Count
        strAddress = .Areas(i).Address
        ar = Split(Replace(Mid(strAddress, 2), ":", ""), "$")
        TimeA = (ws.Cells(ar(3), "B") - ws.Cells(ar(1), "B")) * 24
        FirstAvg = WorksheetFunction.Average(.Areas(i).Offset(, 1))
        SecondAvg = WorksheetFunction.AverageIf(.Areas(i).Offset(, 1), ">=" & 490)
        '
        'write those variables to the sheet
        'the first 505 row of each area would be  .Areas(i).Rows(1).Row
        '
    Next i
End With
then you'd need to do the same sort of thing filtering for >=490 in column D and get TimeB the same way.
Reply With Quote