title: Conditional Data Validation based on Dropdown List Response
body: <p>I am using Microsoft Excel 2013 for Windows. I am trying to set up a data validation using VBA code provided in a different thread (<a href="https://stackoverflow.com/questions/15289462/allow-cell-population-according-to-other-cells-contents">Allow cell population according to other cell&#39;s contents</a>), but am running into issues. </p>
  
  <p>I have a data validation list set up in Column E of the worksheet with list options of "Yes", "No", "N/A". If the user selects "No" or "N/A", I would like "N/A" to automatically appear in Column F and have the cell locked from editing. If the user selects "Yes", then I would like Column F to be unlocked and for the user to be able to enter a number (any number). </p>
  
  <p>Below is the code I am using in VBA. When I run it, I am getting and error that highlights the line of code "If (Target = "No") Or (Target = "N/A") Then" and a box that says "Type Mismatch". Any suggestions? Thanks so much!</p>
  
  <pre><code>Private Sub Worksheet_Change(ByVal Target As Range)
  
  
  ActiveSheet.Unprotect Password:="Your Password"
  Application.EnableEvents = False
  
  
  If Not Intersect(Range("E:E"), Target) Is Nothing Then
  If (Target = "No") Or (Target = "N/A") Then
  Target.Offset(0, 1).Validation.Delete
  Target.Offset(0, 1) = "n/a"
  Target.Offset(0, 1).Locked = True
  Else
  Target.Offset(0, 1).Locked = False
  
  End If
  End If
  
  
  Application.EnableEvents = True
  ActiveSheet.Protect Password:="Your Password"
  End Sub
  </code></pre>