Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. Private Sub Date_Errors()
  2. Dim MyRng As Variant
  3. Set MyRng = ActiveSheet.Range("A2", "A4")
  4. For Each cell In MyRng
  5. If IsDate(cell) Then ' make sure the cell has a date
  6. If cell.Value < Date Then
  7. MsgBox ("Before")
  8. ElseIf (cell.Value - 1) < Date Then
  9. MsgBox ("Older")
  10. End If
  11. Else
  12. MsgBox ("Not a date")
  13. End If
  14. Next
  15. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement