Como modifico un listbox en excel

Le comento, algo, modifique un poco el código de la listbox,, precisamente para este archivo,, el formulario, se acuerda,,, le mando una foto

Resulta que le añadí otra columna a'l cuadro de lista,

"Próxima visita, " columna 12

Le muestro, pero no me salen los datos.

1 respuesta

Respuesta
2

Te paso el código:

Sub Cargar_Lista()
  Dim b As Variant, c As Variant
  Dim i As Long, j As Long, k As Long
  Dim cmb1 As String, txt1 As String, txt2 As String
  '
  ReDim b(1 To UBound(a, 1), 1 To 6)
  Lista.Clear
  '2 programa, 3 tec, 4 mun, 5 nomb, 7 fec, 10 %, 12 prox
  For i = 1 To UBound(a, 1)
    If ComboBox1.Value = "" Then cmb1 = a(i, 2) Else cmb1 = ComboBox1.Value
    If TextBox1.Value = "" Then txt1 = a(i, 3) Else txt1 = TextBox1.Value
    If TextBox2.Value = "" Then txt2 = a(i, 4) Else txt2 = TextBox2.Value
    If LCase(a(i, 2)) = LCase(cmb1) And _
       LCase(a(i, 3)) Like LCase(txt1) & "*" And _
       LCase(a(i, 4)) Like LCase(txt2) & "*" Then
      j = j + 1
      b(j, 1) = a(i, 3)
      b(j, 2) = a(i, 4)
      b(j, 3) = a(i, 5)
      b(j, 4) = a(i, 7)
      b(j, 5) = a(i, 10)
      b(j, 6) = a(i, 12)
    End If
  Next
  If j > 0 Then
    ReDim c(1 To j, 1 To 6)
    For i = 1 To j
      For k = 1 To 6
        c(i, k) = b(i, k)
      Next
    Next
    Lista.List = c
  End If
End Sub

También debes cambiar la propiedad del Listbox ColumnCount a 6

Y  también agregar la longitud en la propiedad del Listbox ColumnWidths a 180 pt;100 pt;220 pt;80 pt;60 pt;80 pt


Añade tu respuesta

Haz clic para o

Más respuestas relacionadas