How should I write the VBA code code below to do the following: If I make a change in…
- User
How should I write the VBA code code below to do the following: If I make a change in F2, if any of the cells in A2, B2, C2, D2, E2, are empty, Clear the entry made in F2, and pop up a message saying 'Request Details Incomplete' new line 'Complete and re-enter date', Then exit the sub If all the cells from A2 to E2 are not empty, Then Call Complete.
If Not Intersect(Target, Range("F2")) Is Nothing Then 'Currently in F2 Call Complete Exit Sub
- Assistant
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Me.Range("F2")) Is Nothing Then 'If change made in F2 If Me.Range("A2").Value = "" Or Me.Range("B2").Value = "" Or Me.Range("C2").Value = "" Or Me.Range("D2").Value = "" Or Me.Range("E2").Value = "" Then 'If any of the cells from A2 to E2 are empty Me.Range("F2").ClearContents 'Clear entry made in F2 MsgBox "Request Details Incomplete" & vbCrLf & "Complete and re-enter date" Exit Sub Else 'If all cells from A2 to E2 are not empty Call Complete End If End If End Sub