Selección con doble clip en un listbox
Tengo un problema con un formulario de búsqueda de vba no puedo hacer selección con 2 clip y pasar ese ítem seleccionado a otra hoja en excel, se me queda en la celda C12 y no me copia en la siguiente fila C13 el otro dato seleccionado
Private Sub CommandButton1_Click()
fila = 12
For x = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(x) = True Then
Cells(fila, 3).Value = ListBox1.List(x, 0)
'Cells(fila, 7).Value = ListBox1.List(x, 1)
Cells(fila, 9).Value = ListBox1.List(x, 2)
'Cells(fila, 9).Value = ListBox1.List(x, 3)
fila = fila + 1
End If
Next
End Sub
Private Sub TextBox1_Change()
NumeroDatos = Hoja2.Range("A" & Rows.Count).End(xlUp).Row
Hoja2.AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
y = 0
For fila = 2 To NumeroDatos
descrip = Hoja2.Cells(fila, 3).Value
If UCase(descrip) Like "*" & UCase(Me.TextBox1.Value) & "*" Then
Me.ListBox1.AddItem
Me.ListBox1.List(y, 0) = Hoja2.Cells(fila, 1).Value
Me.ListBox1.List(y, 1) = Hoja2.Cells(fila, 2).Value
Me.ListBox1.List(y, 2) = Hoja2.Cells(fila, 3).Value
y = y + 1
End If
Next
End Sub
Private Sub TextBox2_Change()
NumeroDatos = Hoja2.Range("A" & Rows.Count).End(xlUp).Row
Hoja2.AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
y = 0
For fila = 2 To NumeroDatos
Parte = Hoja2.Cells(fila, 1).Value
If UCase(Parte) Like "*" & UCase(Me.TextBox2.Value) & "*" Then
Me.ListBox1.AddItem
Me.ListBox1.List(y, 0) = Hoja2.Cells(fila, 1).Value
Me.ListBox1.List(y, 1) = Hoja2.Cells(fila, 2).Value
Me.ListBox1.List(y, 2) = Hoja2.Cells(fila, 3).Value
y = y + 1
End If
Next
End Sub
Private Sub UserForm_Activate()
Me.ListBox1.RowSource = "PRODUCTOS"
Me.ListBox1.ColumnCount = 3
Me.ListBox1.ColumnHeads = True
Me.ListBox1.ColumnWidths = "50;35;180"
End Sub
1 respuesta
Respuesta de Elsa Matilde
1
