Macro para copiar filas de celdas en negativo

Tengo una hoja "resultados" que en las celdas de la columna M tienen valores positivos y negativos

Necesitaría que copiase todas las filas de los valores negativos y los pasase a la hoja "analizar" desde la celda A1

2 respuestas

Respuesta
1

Te anexo la macro

Sub Analizar_Negativos()
'   Por Dante Amor
    Set h1 = Worksheets("resultados")   'origen
    Set h2 = Worksheets("analizar")     'destino
    If h1.AutoFilterMode Then h1.AutoFilterMode = False
    u = h1.Range("M" & Rows.Count).End(xlUp).Row
    h1.Range("A1:M" & u).AutoFilter Field:=13, Criteria1:="<0"
    h1.Rows("1:" & u).Copy h2.Range("A1")
    If h1.AutoFilterMode Then h1.AutoFilterMode = False
    MsgBox "Negativos copiados"
End Sub


[No olvides valorar la respuesta
Respuesta
-1

Prueba con esta macro

Sub copiar_datos()
Set h1 = Worksheets("resultados")
Set h2 = Worksheets("analizar")
h1.Range("m1").CurrentRegion.Columns(1).Copy
h2.Range("a1").PasteSpecial
Set lista = h2.Range("a1").CurrentRegion
With lista
    Range("b1").Value = 1
    Range("b1").AutoFill Destination:=Range(lista.Columns(2).Address), Type:=xlFillSeries
    Set lista = .CurrentRegion
    .Sort key1:=Range("a1"), order1:=xlAscending
    cuenta = WorksheetFunction.CountIf(.Columns(1), ">=0")
    .Rows(.Rows.Count - cuenta + 1).Resize(cuenta).ClearContents
    .Sort key1:=Range("b1"), order1:=xlAscending
    Range("b:b").ClearContents
End With
Set lista = Nothing: Set h1 = Nothing: Set h2 = Nothing
End Sub

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas