Como restaurar valores eliminados de stock

Para Dante Amor

Buenas Dan!

Sabes que en ayuda que prestaste con el tema anterior de rebajar stock "Como restar stock empezando por la mayor cantidad"

Debo tener otro botón que recupere los valores que se descontaron...

Esta este codigo con el que descuenta desde el valor al mayor

Private Sub CommandButton14_Click()
    'On Error Resume Next
    Application.ScreenUpdating = True
    If TextBoxCantidad_Reb = "" Or TextBoxCantidad_Reb = 0 Then
        MsgBox ("Ingrese cantidad mayor a cero")
        TextBoxCantidad_Reb = ""
        TextBoxCantidad_Reb.SetFocus
        Exit Sub
    End If
    '
    If ListBox2.ListCount = 0 Then
        MsgBox "No hay registro en el list"
        TextBoxCantidad_Reb.SetFocus
        Exit Sub
    End If
    '
    If ComboBoxCodigo_Reb = "" Or ComboBoxLote_Reb = "" Then
        MsgBox "Selecciona los combos"
        ComboBoxCodigo_Reb.SetFocus
        Exit Sub
    End If
    '
    For i = 0 To ListBox2.ListCount - 1
        If ListBox2.List(i, 0) = ComboBoxCodigo_Reb And _
           ListBox2.List(i, 1) = ComboBoxLote_Reb Then
            stockdisp = CDbl(ListBox2.List(i, 3))
            If CDbl(TextBoxCantidad_Reb) > stockdisp Then
                MsgBox "La cantidad es mayor al disponible"
                TextBoxCantidad_Reb.SetFocus
                Exit Sub
            End If
            Exit For
        End If
    Next
    '
    Set h = Sheets("Registros")
    Set r = h.Columns("A")
    Set b = r.Find(ComboBoxCodigo_Reb, lookat:=xlWhole)
    If Not b Is Nothing Then
        ncell = b.Address
        Do
            'detalle
            If h.Cells(b.Row, "B") = ComboBoxLote_Reb Then
                Call ordenarstock(h.Cells(b.Row, "G"), b.Row)
            End If
            Set b = r.FindNext(b)
        Loop While Not b Is Nothing And b.Address <> ncell
    End If
    '
    cant_rebajar = CDbl(TextBoxCantidad_Reb)
    For i = 1 To valores.Count
        wval = valores(i)
        wfil = filas(i)
        If wval > 0 Then
            If wval <= cant_rebajar Then
                h.Cells(wfil, "F") = h.Cells(wfil, "F") + wval
                h.Cells(wfil, "G") = h.Cells(wfil, "G") - wval
                cant_rebajar = cant_rebajar - wval
            Else
                h.Cells(wfil, "F") = h.Cells(wfil, "F") + cant_rebajar
                h.Cells(wfil, "G") = h.Cells(wfil, "G") - cant_rebajar
                cant_rebajar = 0
            End If
            If cant_rebajar = 0 Then Exit For
        End If
    Next
    Set valores = Nothing
    Set filas = Nothing
    ComboBoxCodigo_Reb_Change
    TextBoxCantidad_Reb = ""
    MsgBox "Rebaja actualizada", vbInformation, "REBAJAS"
End Sub

Lo que deseo es que si en el caso que haga un descuento mal hecho pueda volver atras con los valores de la ultima rebaja que se hizo!!

1 respuesta

Respuesta
2

H o l a:

Para deshacer un descuento, se tiene que diseñar una especie de control de descuentos.

Se me ocurre que en otra hoja, por cada descuento que realices, asignes un número de folio, en esa hoja se deberán registrar todos los movimientos que realizó el descuento, es decir, tienes que registras de qué código y de qué lote y cuánto descontaste.

Una vez que tengas esos registros, con una herramienta, podrás seleccionar el número de folio que quieras deshacer, la macro deberá verificar si es posible realizar el movimiento y ejecutarlo.

Entonces, lo primero que debes hacer, es registrar en esa hoja de control de descuentos, los movimientos en el momento de realizar el descuento.

Sal u dos

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas