title: Delete conditional in Excel VBA
body: <p>I am stuck in Excel VBA code. I want my delete button to check two conditions. If all meet requirements, than delete, otherwise nothing. I have two sheets. One sheet record delete if another sheet have no any record.</p>
  <p>Below is my current code. My second sheet name is trial balance. I want if textbox4 value check in second sheet and found and also found any value in front of 4 column, so select entry will not delete other wise delete.</p>
  <p>I don't feel my English is very good, so I may not have described things quite the way you are expecting.</p>
  <pre><code>Private Sub CommandButton8_Click()
  Dim I As Long
  Dim W As Worksheet
  Dim Z As Long
  Dim cDelete As VbMsgBoxResult
  Set W = Sheets(&quot;Chart of Account&quot;)
  Z = W.Range(&quot;C&quot; &amp; Rows.Count).End(xlUp).Row
  For I = 8 To Z
  If W.Cells(I, 2).Value = TextBox4.Text Then
  cDelete = MsgBox(&quot;ARE YOU SURE THAT YOU WANT TO DELETE THIS RECORD&quot;, vbYesNo)
  If cDelete = vbYes Then
  W.Rows(I).Delete Shift:=xlUp
  End If
  End If
  Next I
  </code></pre>