Private Sub Worksheet_Change(ByVal Target As Range)
'Check if the changed cell(s) intersect with column E or F)
If Not Intersect(Target, Range("E:F")) Is Nothing Then
'Check if the number of cells changed is 1. If it is more than one, it causes complications.
If Target.Count = 1 Then
'Check if column E and F of the changed rell row are both filled in.
If Cells(Target.Row, 5) <> "" And Cells(Target.Row, 6) <> "" Then
'Add the formula into column G of the changed cell row.
Cells(Target.Row, 7).Formula = "=NETWORKDAYS(" & Cells(Target.Row, 5).Address & ", " & Cells(Target.Row, 6).Address & ")"
End If
End If
End If
End Sub
Bookmarks