Tengo un Listbox con 20 columnas pero sólo me muestra 10
Tengo un listbox con 20 columnas pero sólo me muestra 10. El código es el siguiente:
Private Sub CommandButton1_Click()
Unload Me
End Sub
Private Sub Label2_Click()
End Sub
Private Sub Label3_Click()
End Sub
Private Sub ListBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
On Error Resume Next
If KeyAscii = 13 Then
Set a = Sheets("Hoja1")
filaedit = a.Range("A" & Rows.Count).End(xlUp).Row + 1
fila = Me.ListBox1.ListIndex
a.Cells(filaedit, "A") = ListBox1.List(fila, 0)
a.Cells(filaedit, "B") = ListBox1.List(fila, 1)
a.Cells(filaedit, "C") = ListBox1.List(fila, 2)
a.Cells(filaedit, "D") = ListBox1.List(fila, 3)
a.Cells(filaedit, "E") = ListBox1.List(fila, 4)
a.Cells(filaedit, "F") = ListBox1.List(fila, 5)
a.Cells(filaedit, "G") = ListBox1.List(fila, 6)
a.Cells(filaedit, "H") = ListBox1.List(fila, 7)
a.Cells(filaedit, "I") = ListBox1.List(fila, 8)
a.Cells(filaedit, "J") = ListBox1.List(fila, 9)
a.Cells(filaedit, "K") = ListBox1.List(fila, 10)
a.Cells(filaedit, "L") = ListBox1.List(fila, 11)
a.Cells(filaedit, "M") = ListBox1.List(fila, 12)
a.Cells(filaedit, "N") = ListBox1.List(fila, 13)
a.Cells(filaedit, "O") = ListBox1.List(fila, 14)
a.Cells(filaedit, "P") = ListBox1.List(fila, 15)
a.Cells(filaedit, "Q") = ListBox1.List(fila, 16)
a.Cells(filaedit, "R") = ListBox1.List(fila, 17)
a.Cells(filaedit, "S") = ListBox1.List(fila, 18)
a.Cells(filaedit, "T") = ListBox1.List(fila, 19)
End If
End Sub
Private Sub TextBox1_Change()
On Error Resume Next
Set b = Sheets("Tercero_A")
uf = b.Range("A" & Rows.Count).End(xlUp).Row
If Trim(TextBox1.Value) = "" Then
'Me.ListBox1.List() = b.Range("A8:T" & uf).Value
Me.ListBox1.RowSource = "Tercero_A!A8:T" & uf
Exit Sub
End If
b.AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
For i = 2 To uf
strg = b.Cells(i, 2).Value
If UCase(strg) Like UCase(TextBox1.Value) & "*" Then
Me.ListBox1.AddItem b.Cells(i, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = b.Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = b.Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = b.Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = b.Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = b.Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = b.Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = b.Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = b.Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 9) = b.Cells(i, 10)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 10) = b.Cells(i, 11)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 11) = b.Cells(i, 12)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 12) = b.Cells(i, 13)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 13) = b.Cells(i, 14)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 14) = b.Cells(i, 15)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 15) = b.Cells(i, 16)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 16) = b.Cells(i, 17)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 17) = b.Cells(i, 18)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 18) = b.Cells(i, 19)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 19) = b.Cells(i, 20)
End If
Next i
Me.ListBox1.ColumnWidths = "25pt; 150pt; 0pt; 0pt; 0pt; 0pt; 50pt; 50pt; 50pt; 50pt; 0pt; 50pt; 50pt; 50pt; 0pt; 0pt; 0pt; 0pt; 0pt; 50pt"
End Sub
Private Sub TextBox2_Change()
On Error Resume Next
Set b = Sheets("Tercero_A")
uf = b.Range("A" & Rows.Count).End(xlUp).Row
If Trim(TextBox2.Value) = "" Then
'Me.ListBox1.List() = b.Range("A8:T" & uf).Value
Me.ListBox1.RowSource = "Tercero_A!A8:T" & uf
Exit Sub
End If
b.AutoFilterMode = False
Me.ListBox1 = Clear
Me.ListBox1.RowSource = Clear
For i = 2 To uf
strg = b.Cells(i, 1).Value
If UCase(strg) Like UCase(TextBox2.Value) & "*" Then
Me.ListBox1.AddItem b.Cells(i, 1)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 1) = b.Cells(i, 2)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 2) = b.Cells(i, 3)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 3) = b.Cells(i, 4)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 4) = b.Cells(i, 5)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 5) = b.Cells(i, 6)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 6) = b.Cells(i, 7)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 7) = b.Cells(i, 8)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 8) = b.Cells(i, 9)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 9) = b.Cells(i, 10)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 10) = b.Cells(i, 11)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 11) = b.Cells(i, 12)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 12) = b.Cells(i, 13)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 13) = b.Cells(i, 14)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 14) = b.Cells(i, 15)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 15) = b.Cells(i, 16)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 16) = b.Cells(i, 17)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 17) = b.Cells(i, 18)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 18) = b.Cells(i, 19)
Me.ListBox1.List(Me.ListBox1.ListCount - 1, 19) = b.Cells(i, 20)
End If
Next i
Me.ListBox1.ColumnWidths = "25pt; 150pt; 0pt; 0pt; 0pt; 0pt; 50pt; 50pt; 50pt; 50pt; 0pt; 50pt; 50pt; 50pt; 0pt; 0pt; 0pt; 0pt; 0pt; 50pt"
End Sub
Private Sub UserForm_Initialize()
Dim fila As Long
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Set b = Sheets("Tercero_A")
uf = b.Range("A" & Rows.Count).End(xlUp).Row
uc = b.Cells(1, Columns.Count).End(xlToLeft).Address
wc = Mid(uc, InStr(uc, "$") + 1, InStr(2, uc, "$") - 2)
With Me.ListBox1
.ColumnCount = 20
.ColumnWidths = "25pt; 150pt; 0pt; 0pt; 0pt; 0pt; 50pt; 50pt; 50pt; 50pt; 0pt; 50pt; 50pt; 50pt; 0pt; 0pt; 0pt; 0pt; 0pt; 50pt"
.RowSource = "Tercero_A!A8:" & wc & uf
End With
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
PREGUNTA: ¿Cuál será el error?
Anticipadamente.