Cómo sumar y restar con textbox.
Soy un inexperto en excel, tengo una tienda y quisiera hacer un tipo punto de venta, intente con los de Internet pero me desagradan mucho, y quisiera algo simple en excel, encontré una pagina donde me facilitaron el código para hacer un formulario. Les agrego el mismo para su revisión. Quiero agregar un textbox2 y un texbox3 al final para que en el textbox2 agregue la cantidad que me esta pagando el cliente y en el textbox3 me aparezca el cambio que debo darle. Pero no se como restar del lblTotal el textbox 2 y que me aparezca en automatico en el textbox3. Gracias
Private Sub CommandButton4_Click()
Unload Me
End Sub
'
Private Sub CommandButton5_Click()
'Guardar compra en tabla
Dim i As Variant
Dim j As Variant
Dim TransRowRng As Range
Dim NewRow As Integer
'
With VENTAS
'
For i = Me.ListBox1.ListCount To 1 Step -1
'
Set TransRowRng = ThisWorkbook.Worksheets("VENTAS").Cells(1, 1).CurrentRegion
NewRow = TransRowRng.Rows.Count + 1
.Cells(NewRow, 1).Value = Date
.Cells(NewRow, 2).Value = Me.txtConsec.Value
'
For j = 0 To 4
'
.Cells(NewRow, j + 3).Value = Me.ListBox1.List(Me.ListBox1.ListCount - i, j)
'
Next j
'
Next i
'
End With
'
MsgBox "Registros guardados con éxito.", vbInformation, "EXCELeINFO"
'
Unload Me
'
End Sub
Private Sub CommandButton6_Click()
'Eliminar producto capturado erroneamente.
'
'Declaramos variables
Dim Cuenta As Integer
Dim Numero As Integer
Dim j As Integer
Dim i As Integer
Dim strNombreItem As String
Dim CantidadSeleccionado As String
Dim TotalSeleccionado As Double
'
Cuenta = Me.ListBox1.ListCount
Numero = 0
'
'Validamos que haya un elemento seleccionado.
For j = 0 To Cuenta - 1
If Me.ListBox1.Selected(j) = True Then
Numero = Numero + 1
End If
Next j
'
If Numero <> 0 Then
'
'La hoja seleccionada se pasará al ListBox de hojas visibles.
For i = 0 To Cuenta - 1
If Me.ListBox1.Selected(i) = True Then
strNombreItem = Me.ListBox1.List(i)
CantidadSeleccionado = ListBox1.List(i, 2)
TotalSeleccionado = ListBox1.List(i, 4)
Me.ListBox1.RemoveItem i
Me.lblProductos.Caption = _
WorksheetFunction.Text(Me.lblProductos.Caption - CantidadSeleccionado, "#,##0")
Me.lblTotal.Caption = _
WorksheetFunction.Text(Me.lblTotal.Caption - TotalSeleccionado, "$#,##0.00;-$#,##0.00")
End If
Next i
'
End If
'
End Sub
Private Sub UserForm_Initialize()
Dim intConsecutivo As String
'
Me.ListBox1.ColumnCount = 5
Me.ListBox1.ColumnWidths = "70 pt; 150 pt; 55 pt; 60 pt; 60 pt"
Me.txtFecha.Value = Date
'
intConsecutivo = VENTAS.Range("I1").Value
'
If intConsecutivo = "CONSECUTIVO" Then
'
Me.txtConsec = 1
'
Else
'
Me.txtConsec = intConsecutivo + 1
'
End If
End Sub
1 respuesta
Respuesta de Jaime Luna
1
