Por que no empieza desde la ultima celda con datos
Tengo una duda en mi macro que estoy usando tengo 3 pestañas donde me elimina los valores igual o menor a cero 0 pero no en todas las pestañas corre bien solo en una
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