Mandar datos de factura a hoja compras_lista (excel)

Bien agradecido por sus ayudas y soluciones.

Tengo una factura, ya con todo en orden.

Ahora viene lo difícil, necesito que al dar click en un botón me pase el rango K17:K22 y F25:L67 (las líneas que estén rellenadas) a la hoja "compras_listas".

Y a medida que vaya haciendo compras, las líneas se vayan añadiendo a la cola o que se ordenen por fecha

Dejo dos capturas

Aquí la factura

y aqui la hoja compras_listas (la rellene manualmente y tendria que quedar asi)

Alguna

2 Respuestas

Respuesta
1
Respuesta
1

Te anexo la macro

Sub Mandar_datos_factura_a_compras()
'   Por Dante Amor
    '
    Set h1 = Sheets("factura")
    Set h2 = Sheets("compras_listas")
    '
    fila = 25
    j = h2.Range("F" & Rows.Count).End(xlUp).Row + 1
    Do While h1.Cells(fila, "F").Value <> ""
        h2.Cells(j, "F").Value = h1.Range("K17").Value      'fecha
        h2.Cells(j, "G").Value = h1.Range("K18").Value      'cod prov
        h2.Cells(j, "H").Value = h1.Range("K19").Value      'prov
        h2.Cells(j, "I").Value = h1.Range("K20").Value      'tipo
        h2.Cells(j, "J").Value = h1.Range("K21").Value      'num
        h2.Cells(j, "K").Value = h1.Range("K22").Value      'forma
        h2.Cells(j, "L").Value = h1.Cells(fila, "F").Value  'nomb
        h2.Cells(j, "M").Value = h1.Cells(fila, "G").Value  'cod
        h2.Cells(j, "N").Value = h1.Cells(fila, "H").Value  'precio
        h2.Cells(j, "O").Value = h1.Cells(fila, "I").Value  'cant
        h2.Cells(j, "P").Value = h1.Cells(fila, "J").Value  'importe
        h2.Cells(j, "Q").Value = h1.Cells(fila, "K").Value  'dto
        h2.Cells(j, "R").Value = h1.Cells(fila, "L").Value  'subtot
        h2.Cells(j, "S").Value = h1.Range("L69").Value      'total
        j = j + 1
        fila = fila + 1
    Loop
    MsgBox "Datos enviados"
End Sub

'.[Sal u dos. Dante Amor. No olvides valorar la respuesta. 
'.[Avísame cualquier duda

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas