title: Deleting a row from a table based on 2 criteria (1 Criteria working)
body: <p>This code is inside of a module and it is activated when i select a cell then press my button "delete note". I was getting constant errors trying to write this so i turned to google and tried someone else's method which used filtering but it wouldn't work and i didn't like how it had to activate the sheet which contained the table anyway so i gave it another go writing my own code and have it almost working.</p>
  
  <p>If i change this line:</p>
  
  <pre><code>If .DataBodyRange.Cells(Counter, .ListColumns("Name").Index) = EmployeeName And .DataBodyRange.Cells(Counter, .ListColumns("Date").Index) = SelectedDate Then
  .ListRows(Counter).Delete
  </code></pre>
  
  <p>To this, then the macro works but obviously its deleted all names linked to that date instead of the name in cell "B3" on Sheet "Calendar"</p>
  
  <pre><code>If .DataBodyRange.Cells(Counter, .ListColumns("Date").Index) = SelectedDate Then
  .ListRows(Counter).Delete
  </code></pre>
  
  <p>If i change it to this, i get a type mismatch error</p>
  
  <pre><code>If .DataBodyRange.Cells(Counter, .ListColumns("Name").Index) = EmployeeName
  </code></pre>
  
  <p>Full Code Below</p>
  
  <pre><code>    Dim Counter As Integer, EmployeeName As Integer, LastRow As Integer, SelectedDate As Date
  
  
      If Intersect(ActiveCell, range("D12:AS23")) Is Nothing Then
          MsgBox "Please select a date.", , "Error"
          Exit Sub
      Else
          If Sheets("Settings").range("Protected") = 2 Then
              With Sheets("Calendar")
                  SelectedDate = Cells(ActiveCell.Row, 2) - 1 + ActiveCell.Value
                  EmployeeName = range("B3")
              End With
              With Sheets("Notes").ListObjects("TblNotes")
                  LastRow = .range.Rows.Count
                  For Counter = LastRow To 1 Step -1
                  If .DataBodyRange.Cells(Counter, .ListColumns("Name").Index) = EmployeeName And .DataBodyRange.Cells(Counter, .ListColumns("Date").Index) = SelectedDate Then
                      .ListRows(Counter).Delete
                  End If
                  Next Counter
              End With
          Else
              'do nothing
          End If
      End If
  </code></pre>