Imput box que admita cantidades y haga resta simulado inventario
Tengo un formulario el cual en el boton REGISTRAR tengo este codigo...
Private Sub CommandButton1_Click()
'Registrar producto y capturar cantidad
'Declaramos variables
Dim strDescripcion As String
Dim intCantidad As Double
Dim doublePUnitario As Double
Dim intTotal As Double
'
'En caso de error
On Error GoTo ErrorHandler
'
With Application.WorksheetFunction
'
'Usamos BUSCARV para encontrar el detalle del producto
'
strDescripcion = . VLookup(CDbl(Me. TextBox1. Value), PRODUCTOS.Range("A:C"), 2, 0)
'
intCantidad = InputBox(strDescripcion & vbNewLine & vbNewLine & "Ingresa la cantidad.", "Cantidad", 1)
'
If intCantidad = 0 Then GoTo ErrorHandler
'
'Llenamos el ListBox
'... CÓDIGO
Me.ListBox1.AddItem Me.TextBox1.Value
'
'... DESCRIPCIÓN
ListBox1.List(ListBox1.ListCount - 1, 1) = strDescripcion
'
'... CANTIDAD
ListBox1.List(ListBox1.ListCount - 1, 2) = .Text(intCantidad, "#,##0")
'
'... P.UNITARIO
doublePUnitario = . VLookup(CDbl(Me. TextBox1. Value), PRODUCTOS.Range("A:C"), 3, 0)
ListBox1.List(ListBox1.ListCount - 1, 3) = .Text(doublePUnitario, "$#,##0.00;-$#,##0.00")
'
'... TOTAL
intTotal = doublePUnitario * intCantidad
ListBox1.List(ListBox1.ListCount - 1, 4) = .Text(intTotal, "$#,##0.00;-$#,##0.00")
'
'...ETIQUETAS
Me.lblProductos = .Text(CInt(Me.lblProductos) + CInt(intCantidad), "#,##0")
Me.lblTotal = .Text(CDbl(Me.lblTotal) + CDbl(intTotal), "$#,##0.00;-$#,##0.00")
'
Me.TextBox1.Value = ""
Me.TextBox1.SetFocus
'
End With
'
Exit Sub
'
ErrorHandler:
'
MsgBox "Ha ocurrido un error: " & Err.Description, vbExclamation, "EXCELeINFO"
'
Me.TextBox1.Value = ""
Me.TextBox1.SetFocus
'
End Suben una hoja llamada PRODUCTOS tengo una lista de
Columna A esta el codigo
Columna B el producto
Columna C el precio
Entonces quisiera agregar en la columna D otro que se llame INVETARIO
El cual al salir esto al dar clic al boton REGISTRAR:
intCantidad = InputBox(strDescripcion & vbNewLine & vbNewLine & "Ingresa la cantidad.", "Cantidad", 1)
Me pide cantidad del producto pero nose como adaptar que si tengo 5 unidades de cada producto y al poner 7 en el imputbox este no me permita ya que no0 tengo suficientes unidades para vender...
1 Respuesta
Respuesta de numerobix PlanetaInformatico.es
1