ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
Morning,
I am using the code below & also attach a screenshot of the userform.
As you can see the Listbox shows all the codes taken from column J when the userform is open.
What i would like is to know / happen is how many entries are in the ListBox & then put that figure in the TextBox1
So i would open the userform, the listbox entries are loded, TextBox1 would show example 59
I did try this but TextBox was still blanl.
I am using the code below & also attach a screenshot of the userform.
As you can see the Listbox shows all the codes taken from column J when the userform is open.
What i would like is to know / happen is how many entries are in the ListBox & then put that figure in the TextBox1
So i would open the userform, the listbox entries are loded, TextBox1 would show example 59
I did try this but TextBox was still blanl.
Rich (BB code):
Private Sub TextBox1_Click()
ListBox1.ListCount
End Sub
Rich (BB code):
Private Sub UserForm_Initialize()
With ThisWorkbook.Worksheets("DATABASE")
Dim data As Variant
data = .Range("J6:K" & .Cells(.Rows.Count, "J").End(xlUp).Row).Value
End With
ReDim arr(0 To 1, 0 To UBound(data) - 1) As String
Dim itm As String
Dim cnt As Long
Dim i As Long
cnt = 0
For i = LBound(data) To UBound(data)
itm = data(i, 1)
If itm Like "[A-Za-z]###" Then
arr(0, cnt) = itm
arr(1, cnt) = data(i, 2)
cnt = cnt + 1
End If
Next i
If cnt > 1 Then
ReDim Preserve arr(0 To 1, 0 To cnt - 1)
Sort2DArray arr()
Me.ListBox1.List = Application.Transpose(arr())
ElseIf cnt > 0 Then
Me.ListBox1.Column = arr()
End If
End Sub