title: Excel VBA using NETWORKDAYS
body: <p>I have created a sub that checks if changes has happened in column <code>F</code> and writes the timestamp to a corresponding cell in column <code>G</code>. How do i edit this sub to return the network days in column <code>H</code> by finding the difference between the timestamp in column H and Cell containing a week commencing date <code>A1</code>? Without VBA, the formula is <code>=ABS(NETWORKDAYS(A1, B1) - SIGN(NETWORKDAYS(A1, H1))</code>. Below is my code so far. Any help? </p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Range, c As Range
    Application.EnableEvents = False
    With Target
      'check if change happened in column F
      If .Column = 6 Then
        'check if changed value is X
        If Not IsEmpty(c) Then
          'add datestamp if it is
           Cells(.Row, 7).Value = Format(DateTime.Now, "yyyy-MM-dd hh:mm:ss")
           Cells(.Row, 8).Value = ABS(NETWORKDAYS(G5,H2)-SIGN(NETWORKDAYS(G5,H2)
        Else
          'clear datestamp and Column H if not
          Cells(.Row, 7).Value = ""
          Cells(.Row, 8).Value = ""
        End If
      End If
    End With
    Application.EnableEvents = True
  End Sub 
  </code></pre>
  
  <p>'</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
    Dim r As Range, c As Range
    Dim d1 As Date, d2 As Date, wf As WorksheetFunction
    Dim N As Long
  
    Set wf = Application.WorksheetFunction
    Application.EnableEvents = False
    With Target
      'check if change happened in column F
      If .Column = 2 Then
        'check if changed value is X
        If Not IsEmpty(c) Then
          'add datestamp if it is
          d1 = Cells.Range("A1")
          d2 = Cells.Range("B1:B2")
          N = wf.NetworkDays(d1, d2)
          Cells(.Row, 4).Value = N
  
        Else
          'clear datestamp and Colunm H if not
          Cells(.Row, 4).Value = ""
        End If
      End If
    End With
    Application.EnableEvents = True
  End Sub
  </code></pre>