I have an issue when deleting rows with certain conditions because it deletes my headers too, also ¿ is there a way to improving the deleting of rows with different criteria ?
Sub RO_FilterDelete()
Dim RowToTest As Long
For RowToTest = Cells(Rows.Count, 2).End(xlUp).row To 2 Step -1
With Cells(RowToTest, 1)
If .Value <> "ONLINE" _
Then _
Rows(RowToTest).EntireRow.Delete
End With
Next RowToTest
Dim RowToTest2 As Long
For RowToTest2 = Cells(Rows.Count, 2).End(xlUp).row To 2 Step -1
With Cells(RowToTest2, 6)
If .Value <> "CONFIRMACIÓN DE INFORMACIÓN DE CONTRATO" _
And .Value <> "ACTUALIZACIÓN DE INFORMACIÓN DE CONTRATO" _
Then _
Rows(RowToTest2).EntireRow.Delete
End With
Next RowToTest2
End Sub
The error comes from the macro that paste the data into the worksheet, it pastes it from A1 instead of A2, that's why the filter doesn't work.
Sub RechazosOnline()
Dim rsh As Worksheet, wb As Workbook
Dim wbCopyFrom As Workbook, wsCopyFrom As Worksheet
Set wb = Workbooks("2. Detalle_Transacciones_pendientes_rechazadas_MDM_27Ene20.xlsx")
Set wbCopyFrom = Workbooks("1. ReporteGeneral_TransaccionesDiariasMDM_20200115")
Set wsCopyFrom = wbCopyFrom.Worksheets("Detalle")
wsCopyFrom.Range("A2:I" & wsCopyFrom.Range("A" & Rows.Count).End(xlUp).row).Copy
For Each rsh In wb.Sheets
rsh.Range("A2:I" & rsh.Range("A" & rsh.Cells.Rows.Count).End(xlUp).row).PasteSpecial xlPasteValues
Next
End Sub