Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim priceRange As Range
- startRowNum = GetFirstRow(StartTime) << THIS TAKE 10 SECONDS
- endRowNum = GetLastRow(endTime) << THIS TAKE 10 SECONDS
- Set priceRange = Range(Cells(startRowNum, 4), Cells(endRowNum, 4))
- targetRange.Offset(0, 2).Value = Application.WorksheetFunction.Max(priceRange)
- targetRange.Offset(0, 3).Value = Application.WorksheetFunction.Min(priceRange)
- Function GetFirstRow(T As Date) As Long
- 'Starts at FirstRow and returns the first row where the time is greater than T1.
- Dim currentRow As Long
- Dim CompareTime As Date
- Dim CompareDate As Date
- currentRow = 4 'Start at row4 due to headers.
- Do While (IsDate(Cells(currentRow, 2)))
- CompareDate = Cells(currentRow, 2)
- CompareTime = Cells(currentRow, 3)
- marketTime = CompareDate + CompareTime
- If (marketTime >= T) Then Exit Do
- currentRow = currentRow + 1
- Loop
- GetFirstRow = currentRow
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement