Macro no resta valores del inventario

Para Matilde.

Buen día.

Tengo una macro en la que ingreso valores a un inventario por medio de un formulario, si hago una adición la suma bien pero cuando quiero hacer una devolución no me la toma.

Private Sub BASE_Click()
Application.ScreenUpdating = False
Sheets("ALMACEN").Select
ActiveSheet.Unprotect ("80178848")
Range("B2").Select
Do Until ActiveCell.Offset(0, 0) = ""
    If ActiveCell.Offset(0, 0) = BASE Then
    Label16 = ActiveCell.Offset(0, 7)
    Label19 = ActiveCell.Offset(0, 6)
    End If
ActiveCell.Offset(1, 0).Select
Loop
ActiveSheet.Protect ("80178848"), AllowFiltering:=True
Sheets("ENTREGAS").Select
ActiveSheet.Unprotect ("80178848")
Range("A3").Select
Dim cantcontra As Single
cantcontra = 0
Do Until ActiveCell.Offset(0, 0) = ""
    If ActiveCell.Offset(0, 4) = BASE And ActiveCell.Offset(0, 3) = CONTRATISTA.Text Then
        cantcontra = cantcontra + ActiveCell.Offset(0, 9) - ActiveCell.Offset(0, 10)
    End If
ActiveCell.Offset(1, 0).Select
Loop
Label18 = CDbl(cantcontra)
Sheets("ENTREGAS").Select
If CDbl(Label16) < CDbl(CANTIDAD) And txtbxmovimiento.Text = "ENTREGA" Then
MsgBox ("La Cantidad A Entregar Supera La Disponibildad")
End If
'procedimiento para establecer si la cantidad de equipo por devolver supera a la prestada al contratista
If txtbxmovimiento.Text = "DEVOLUCION" Then
    If CDbl(CANTIDAD) > CDbl(cantcontra) Then
    MsgBox ("Está Generando Una Devolución de Equipo Superior al Prestado al Contratista: " & CONTRATISTA.Text)
    CANTIDAD = 0
    End If
End If
ActiveSheet.Protect ("80178848"), AllowFiltering:=True
Application.ScreenUpdating = True
End Sub

Esta es parte del código y lo que almacena aquí Label18 = CDbl(cantcontra) lo debe mostrar en el label de Prestado Al Contratista.

Ya revisé todo el código y la verdad no encuentro el error solicito

1 respuesta

Respuesta
1

Enviame el libro con el formulario para revisarlo.

Macro enviada al correo.

Gracias.

Ya te devolví el libro con el análisis y posibles razones. Van las pruebas allí.

Sdos!

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas