Macro no elimina desde la ultima celda

Tengo una macro que elimina las celdas que son igual o menor a cero que se aplica en varias pestañas pero solo en una si inicia desde abajo a eliminar

Sub pruebas()
'
' pruebas Macro
'

'

Sheets("S.A").Select
xfila = Range("A" & Rows.Count).End(xlUp).Row
Range("K6").FormulaR1C1 = "=IF(RC[1]-0,RC[1]*-1,RC[1])"
Range("K6").AutoFill Destination:=Range("K6:K" & xfila)
Range("K6", Range("K6").End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
xnfil = Range("J6").End(xlDown).CurrentRegion.Rows.Count
For i = xnfil To 2 Step -1
Cells(i, "K").Select
If Cells(i, "K") < 0 Or Cells(i, "K") = 0 Then
ActiveCell.Select
Selection.ClearContents
End If
Next i

'//
Sheets("INDUSTRIAL").Select
yfila = Range("A" & Rows.Count).End(xlUp).Row
Range("K6").FormulaR1C1 = "=IF(RC[1]-0,RC[1]*-1,RC[1])"
Range("K6").AutoFill Destination:=Range("K6:K" & yfila)
Range("K6", Range("K6").End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ynfil = Range("A6").End(xlDown).CurrentRegion.Rows.Count
For i = ynfil To 2 Step -1
Cells(i, "K").Select
If Cells(i, "K") < 0 Or Cells(i, "K") = 0 Then
ActiveCell.Select
Selection.ClearContents
End If
Next i
Sheets("TECMAN").Select
zfila = Range("A" & Rows.Count).End(xlUp).Row
Range("K6").FormulaR1C1 = "=IF(RC[1]-0,RC[1]*-1,RC[1])"
Range("K6").AutoFill Destination:=Range("K6:K" & zfila)
Range("K6", Range("K6").End(xlDown)).Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
znfil = Range("K6").End(xlDown).CurrentRegion.Rows.Count
For i = znfil To 2 Step -1
Cells(i, "K").Select
If Cells(i, "K") < 0 Or Cells(i, "K") = 0 Then
ActiveCell.Select
Selection.ClearContents
End If
Next i
End Sub

Añade tu respuesta

Haz clic para o