O
Office_Novice
I have a worksheet LOADED w/ info; I have created a UserForm with a textbox,
commadButton and a listbox. When i type a criteria in the textbox in the
information appears in the list box. After a good while I notice more the one
occurrence of said criteria how do I modify the code below to include the
second occurrence in the list box?
Sub CommandButton1_Click()
Dim rng As Range
Dim Ary(6) As String
Dim i As Single
If Me.TextBox1.Value = "" Then
MsgBox "You Must Enter A Number", _
vbExclamation, "Error"
Exit Sub
End If
Set rng = Worksheets(1).Range("A2:A65536").Find _
(Me.TextBox1.Value, LookIn:=xlValues)
If Not rng Is Nothing Then
rng.Select
ListBox1.ColumnCount = 6
For i = 0 To 6
Ary(0) = i
Next i
Ary(0) = ActiveCell.Value
Ary(1) = ActiveCell.Offset(0, 1).Value
Ary(2) = ActiveCell.Offset(0, 2).Value
Ary(3) = ActiveCell.Offset(0, 3).Value
Ary(4) = ActiveCell.Offset(0, 4).Value
Ary(5) = ActiveCell.Offset(0, 5).Value
ListBox1.Column() = Ary
Else
MsgBox Me.TextBox1.Value & _
" Does Not Exist", vbCritical, "Error"
Exit Sub
End If
Me.TextBox1.Value = ""
End Sub
commadButton and a listbox. When i type a criteria in the textbox in the
information appears in the list box. After a good while I notice more the one
occurrence of said criteria how do I modify the code below to include the
second occurrence in the list box?
Sub CommandButton1_Click()
Dim rng As Range
Dim Ary(6) As String
Dim i As Single
If Me.TextBox1.Value = "" Then
MsgBox "You Must Enter A Number", _
vbExclamation, "Error"
Exit Sub
End If
Set rng = Worksheets(1).Range("A2:A65536").Find _
(Me.TextBox1.Value, LookIn:=xlValues)
If Not rng Is Nothing Then
rng.Select
ListBox1.ColumnCount = 6
For i = 0 To 6
Ary(0) = i
Next i
Ary(0) = ActiveCell.Value
Ary(1) = ActiveCell.Offset(0, 1).Value
Ary(2) = ActiveCell.Offset(0, 2).Value
Ary(3) = ActiveCell.Offset(0, 3).Value
Ary(4) = ActiveCell.Offset(0, 4).Value
Ary(5) = ActiveCell.Offset(0, 5).Value
ListBox1.Column() = Ary
Else
MsgBox Me.TextBox1.Value & _
" Does Not Exist", vbCritical, "Error"
Exit Sub
End If
Me.TextBox1.Value = ""
End Sub