I am new to visual basic and need some help with some coding. I have a excel template that has an plan end date and actual end date (2 separate columns) if my actual end date is greater then my plan end date, I need a message box to explain they need to write a comment. If there is no comment the worksheet needs to lock down so they can not do anything. Once the comment is added the worksheet will unlock. I am getting errors and it doesn't look like it is working. Can anyone help me with my code.
Sub CommentNeeded()
Dim date1 As Date
Dim date2 As Date
ActiveSheet.Unprotect ("me")
If date1> date2 Then
Msgbox "You must input a comment to explain the delay. Sheet will be locked until comment is added"
Else
Worksheets("Hardware").Range("J7:J32").Cells.Locked = False
Worksheets("Hardware").Protect
End If
If date1=date2 Then
Worksheets("Hardware"). Unprotect
End If
End Sub
Sub CommentNeeded()
Dim date1 As Date
Dim date2 As Date
ActiveSheet.Unprotect ("me")
If date1> date2 Then
Msgbox "You must input a comment to explain the delay. Sheet will be locked until comment is added"
Else
Worksheets("Hardware").Range("J7:J32").Cells.Locked = False
Worksheets("Hardware").Protect
End If
If date1=date2 Then
Worksheets("Hardware"). Unprotect
End If
End Sub