Seleccionar un item de un combobox y realizar una multiplicación
Tengo una hoja de calculo donde hay 2 columnas con datos numéricos la idea es que cuando seleccione un dato en mi caso particular el de menor valor me realice una multiplicación ejemplo columna D(precio1) columna E(precio2) columna F(cantidad)con un combobox selecciono en mi caso la columna que tenga el menor valor y lo multiplico con la columna "cantidad" todo esto realizado en un formulario envío el código de lo que e tratado de hacer y no me dan los resultados esperados quedando muy agradecido con tan maravilloso foro de antemano muchas gracias
Public pp As Long
Public up As Long
Private Sub ComboBox1_Change()
'Dim Fila As Integer
'Dim Final As Integer
'
'If ComboBox1.Text = "" Then
' Me.TextBox1 = ""
' Me.TextBox3 = ""
' Me.TextBox4 = ""
'End If
'
'Final = GetUltimoR(Hoja2)
'
' For Fila = 2 To Final
' If ComboBox1.Text = Hoja2.Cells(Fila, 1) Then
' Me.txt_Nombre = Hoja2.Cells(Fila, 2)
' Me.txt_Descrip = Hoja2.Cells(Fila, 3)
' Exit For
' End If
' Next
End Sub
Private Sub ComboBox1_Enter()
Dim Fila As Integer
Dim Final As Integer
Dim Lista As String
For Fila = 1 To ComboBox1.ListCount
ComboBox1.RemoveItem 0
Next Fila
Final = GetUltimoR(Sheets(Hoja3.Name))
For Fila = 2 To Final
Lista = Worksheets(Hoja3.Name).Cells(Fila, 2)
ComboBox1.AddItem (Lista)
Next
End Sub
Private Sub CommandButton1_Click()
Dim X As Long
Dim Fila As Long
Dim Final As Long
'titulo = "Registro de productos"
Final = GetNuevoR(Hoja3)
X = ActiveSheet.Range("A1").End(xlDown).Row + 1
Cells(X, 1) = TextBox1.Text
Cells(X, 2) = ComboBox1.List
Cells(X, 10) = ComboBox4.List
For X = 2 To Range("A" & Rows.Count).End(xlUp).Row
pp = Cells(X, 4)
up = Cells(X, 5)
If pp > up Then
pp = Cells(X, 4) * Cells(X, 6)
Else
up = Cells(X, 5) * Cells(X, 6)
' If IsNumeric(Cells(X, 4)) And IsNumeric(Cells(X, 6)) Then
' Cells(X, 10) = Cells(X, 4) * Cells(X, 6)
' Else
' Cells(X, 10) = Cells(X, 5) * Cells(X, 6)
' End If
End If
Next
End Sub
Private Sub UserForm_Initialize()
'Sheets(Hoja3.Name).Select
'
'ComboBox4.List = Array("Precio1", "Precio2")
' KeyAscii = 0
With Me.ComboBox4
.AddItem "Precio1"
.AddItem "Precio2"
End With
End Sub
1 respuesta
Respuesta de Dante Amor
1





