Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Dim priceRange As Range
  2. startRowNum = GetFirstRow(StartTime) << THIS TAKE 10 SECONDS
  3. endRowNum = GetLastRow(endTime) << THIS TAKE 10 SECONDS
  4. Set priceRange = Range(Cells(startRowNum, 4), Cells(endRowNum, 4))
  5. targetRange.Offset(0, 2).Value = Application.WorksheetFunction.Max(priceRange)
  6. targetRange.Offset(0, 3).Value = Application.WorksheetFunction.Min(priceRange)
  7.  
  8. Function GetFirstRow(T As Date) As Long
  9.  
  10. 'Starts at FirstRow and returns the first row where the time is greater than T1.
  11.  
  12. Dim currentRow As Long
  13. Dim CompareTime As Date
  14. Dim CompareDate As Date
  15.  
  16. currentRow = 4 'Start at row4 due to headers.
  17.  
  18. Do While (IsDate(Cells(currentRow, 2)))
  19. CompareDate = Cells(currentRow, 2)
  20. CompareTime = Cells(currentRow, 3)
  21. marketTime = CompareDate + CompareTime
  22. If (marketTime >= T) Then Exit Do
  23. currentRow = currentRow + 1
  24. Loop
  25.  
  26. GetFirstRow = currentRow
  27.  
  28. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement