Guest User

Untitled

a guest
Feb 24th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. Private Sub Worksheet_Change()
  2.  
  3. If IsEmpty(Range("A:A")) = False Then
  4.  
  5. MsgBox "Insert Data in B"
  6. Activecell.Offset(0,1).Activate
  7. Call DateTime
  8.  
  9. Elseif IsEmpty(Range("B:B")) = False Then
  10.  
  11. MsgBox "Insert Data in C"
  12. Activecell.Offset(0,1).Activate
  13.  
  14. Elseif IsEmpty(Range("C:C")) = False Then
  15. Activecell.Offset(1,0).Activate
  16. Call IsEmptyRange
  17. exit sub
  18. Endif
  19.  
  20.  
  21.  
  22. Private Sub DateTime()
  23.  
  24. Dim Cell As Range
  25. For Each Cell In Target
  26. If Cell.Column = Range("A:A").Column Then
  27. If Cell.Value <> "" Then
  28. Cells(Cell.Row, "E").Value = Int(Today)
  29. Cells(Cell.Row, "E").Value =NOW()-TODAY()
  30. Else
  31. Cells(Cell.Row, "E").Value = ""
  32. Cells(Cell.Row, "F").Value = ""
  33. End If
  34. End If
  35. Next Cell
  36.  
  37. Exit Sub
  38. End Sub
  39.  
  40.  
  41.  
  42. Sub IsEmptyRange()
  43.  
  44. Dim cell As Range
  45. Dim bIsEmpty As Boolean
  46.  
  47. bIsEmpty = False
  48. For Each cell In Range("A:C")
  49. If IsEmpty(cell) = True Then
  50.  
  51. bIsEmpty = True
  52. Exit For
  53. End If
  54. Next cell
  55.  
  56. If bIsEmpty = True Then
  57.  
  58. MsgBox "There are empty cells in your range"
  59. Else
  60. 'There are NO empty cells in your range
  61.  
  62. MsgBox "All cells have values!"
  63. End If
  64.  
  65. Exit Sub
  66. End Sub
Add Comment
Please, Sign In to add comment