Resgistro de ventas en libro de ventas videojuegos

Ahora me interesaría validar la venta... Creo que lo mejor seria que se revisen todos los registros y si alguno tiene problemas entonces que detenga toda la venta...

No sabes como te agradezco toda la ayuda... Un saludo.

1 Respuesta

Respuesta
1

Te anexo la macro para las ventas

Sub RegistrarVenta()
'Por.Dante Amor
'Registra Venta, en stock y limpia el formulario
'
    Application.ScreenUpdating = False
    Set h1 = Sheets("STOCK")
    Set h2 = Sheets("SALIDAS")
    Set h3 = Sheets("VENTAS")
    '
    exitosa = True
    For i = 18 To 30
        If h3.Cells(i, "B") = "" Then Exit For
        Set b = h1.Columns("B").Find(h3.Cells(i, "C"), lookat:=xlWhole)
        If Not b Is Nothing Then
            'valida stock
            If h1.Cells(b.Row, "O") < h3.Cells(i, "E") Then
                exitosa = False
                Exit For
            End If
        Else
            errorart = True
            Exit For
        End If
    Next
    If errorart Then
        MsgBox "Código de artículo no encontrado" & h3.Cells(i, "C")
        Exit Sub
    Else
        If exitosa Then
            'Actualiza stock
            For i = 18 To 30
                If h3.Cells(i, "B") = "" Then Exit For
                Set b = h1.Columns("B").Find(h3.Cells(i, "C"), lookat:=xlWhole)
                If Not b Is Nothing Then
                    h1.Cells(b.Row, "O") = h1.Cells(b.Row, "O") - h3.Cells(i, "E")
                End If
                'Actualiza salidas
                u2 = h2.Range("A" & Rows.Count).End(xlUp).Row + 1
                h2.Cells(u2, "A") = h3.[B12]
                h2.Cells(u2, "B") = h3.[B15]
                h2.Cells(u2, "C") = h3.[F8]
                h2.Cells(u2, "D") = h3.Cells(i, "B")
                h2.Cells(u2, "E") = h3.Cells(i, "C")
                h2.Cells(u2, "F") = h3.Cells(i, "D")
                h2.Cells(u2, "G") = h3.Cells(i, "E")
                h2.Cells(u2, "H") = h3.Cells(i, "F")
            Next
        Else
            MsgBox "Inventario insuficiente, para el artículo: " & h3.Cells(i, "C")
            Exit Sub
        End If
    End If
    'Limpia formulario
    h3.Range("F8").ClearContents
    h3.Range("D18:E30").ClearContents
    h3.Range("F8").Select
    Application.ScreenUpdating = True
    MsgBox "Venta registrada"
End Sub

Recuerda crear la hoja "Salidas"


Saludos. Dante Amor

No olvides valorar la respuesta.

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas