Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub date_diff()
- Dim todDate
- Dim dt
- Dim diff As Long
- Dim dates(0 To 9) As Date
- Dim i As Long
- todDate = Format(ActiveWorkbook.Sheets("Overview").Range("B6").Value, "mm/dd/yyyy")
- ' dt is the Date of last signaling
- dt = ActiveWorkbook.Sheets("Overview").Range("B5").Value
- diff = DateDiff("d", dt, todDate)
- Dim rng As Range
- Dim dtCell As Range
- Dim currDt
- If diff < 32 Then
- MsgBox "Wait " & (32 - diff) & " days"
- Else
- For i = 1 To 10
- currDt = Format(DateAdd("d", 20, todDate), "mm/dd/yyyy")
- Set rng = ActiveWorkbook.Sheets("US Stocks").Range("A:A")
- ' Find the day - Loop until you find one at least 30 days apart
- Do While rng.Find(What:=currDt) Is Nothing
- currDt = DateAdd("d", -1, currDt)
- Loop
- dates(i) = currDt
- MsgBox i
- Next i
- End If
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement