I am a fresher in VBA and want to do a VBA as below conditions, could anyone help me? Please……
- Cell J2 us set to be today()
- Cell J4 can be set another date by user
- Cell L4 set a formula =NETWORKDAY(J2-J4)-1, to calculate the exact days between 2 dates in J2 & J4
- if the outcome in L4 is <4, user could continue to fill in the form;
- Otherwise, 2 msg box pop up in sequence
- msgbox : 'Application takes at least 4-7 workings days';
- msgbox : 'Please pick another date'
- return to Cell J4 which will be cleared as well
- User should input the date in J4 again
here is my code, but it doesn't work:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If Range("L4") >= 4 Then Exit Sub
Else
msg = MsgBox("Application takes at least 4-7 working days", vbOKOnly, "Reminder")
Range("J4").Select
Selection.ClearContents
msg = MsgBox("Please choose another date", vbOKOnly)
End If
End sub`