1

I have a VBA macro set up to delete a row based on a value provided in a cell. So I wrote something that is supposed to filter the second column to find the desired value and delete the row. My problem is that for some reason it always deletes the first row no matter what, even if the value is not present in the sheet.

M2 is the cell with the value I want found in the table. The UnMerge part is because it merged some cell and my sort macro wasn't working with merged cells.

Here is the code:

Private Sub DeleteCarte_Click()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("INDEX")
With ws.Range("A6.F600")
    .AutoFilter Field:=2, Criteria1:=Range("M2").Value
    .EntireRow.Delete
End With
Sheets("INDEX").Range("A1:F600").UnMerge
End Sub
BSMP
  • 4,596
  • 8
  • 33
  • 44
JMV
  • 13
  • 2

0 Answers0