Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Sub date_diff()
  2. Dim todDate
  3. Dim dt
  4. Dim diff As Long
  5. Dim dates(0 To 9) As Date
  6. Dim i As Long
  7. todDate = Format(ActiveWorkbook.Sheets("Overview").Range("B6").Value, "mm/dd/yyyy")
  8. ' dt is the Date of last signaling
  9. dt = ActiveWorkbook.Sheets("Overview").Range("B5").Value
  10. diff = DateDiff("d", dt, todDate)
  11. Dim rng As Range
  12. Dim dtCell As Range
  13. Dim currDt
  14. If diff < 32 Then
  15. MsgBox "Wait " & (32 - diff) & " days"
  16. Else
  17. For i = 1 To 10
  18. currDt = Format(DateAdd("d", 20, todDate), "mm/dd/yyyy")
  19. Set rng = ActiveWorkbook.Sheets("US Stocks").Range("A:A")
  20. ' Find the day - Loop until you find one at least 30 days apart
  21. Do While rng.Find(What:=currDt) Is Nothing
  22. currDt = DateAdd("d", -1, currDt)
  23. Loop
  24. dates(i) = currDt
  25. MsgBox i
  26. Next i
  27. End If
  28. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement