title: Excel VBA Change Number format on Cell value change
body: <p>I am having a little difficulty with some Excel visual basic.  Particularly I want to change the format of a column based on the value of a cell.  Here's what I have so far.</p>
  
  <pre><code> Private Sub Worksheet_Change(ByVal Target As Range)
  
      If Target.Address = Range("$b$1") Then
          If Range("$b$1") = "Date" Then
              Range("d:d").NumberFormat = "m/d/yyyy"
          ElseIf Range("$b$1") = "Number" Then
              Range("d:d").NumberFormat = "#,##0.00"
          End If
      End If
  End Sub    
  </code></pre>
  
  <p>I am new to using the Target feature so any advice would be helpful.</p>