Hi, again!
I have managed to put together excel userform for looking up data in excel!
I have created a listbox (two of them) which are filled up in two columns when the criteria meets!
But when I`m testing this thing the error mismatch pops up ( Could not set the List property. Type mismatch. Run-time error `-2147352571 (80020005)` , what does my code is missing??!?!
Here is the code:
Code
Private Sub CommandButton4_Click()
Set xSht = Sheets("kilas")
Lastrow = xSht.Range("A" & Rows.count).End(xlUp).Row
strSearch = krednr.Text
Set aCell = xSht.Range("A2:A" & Lastrow).Find(What:=strSearch, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
row_number = 0
ListBox1.Clear
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("kilas").Range("A" & row_number)
If item_in_review = krednr.Text Then
TextBox10.Text = Sheets("kilas").Range("AE" & row_number)
With Me.ListBox1
Me.ListBox1.ColumnCount = 2
Me.ListBox1.ColumnWidths = "200;2000"
.AddItem
.List(i, 0) = Sheets("kilas").Range("V" & row_number)
.List(i, 1) = Sheets("kilas").Range("X" & row_number)
i = i + 1
End With
End If
Loop Until item_in_review = ""
End Sub
Display More
&
Code
Private Sub CommandButton5_Click()
Set xSht = Sheets("nauda")
Lastrow = xSht.Range("B" & Rows.count).End(xlUp).Row
strSearch = krednr.Text
Set aCell = xSht.Range("B2:B" & Lastrow).Find(What:=strSearch, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
row_number = 0
ListBox2.Clear
Do
DoEvents
row_number = row_number + 1
item_in_review = Sheets("nauda").Range("B" & row_number)
If item_in_review = krednr.Text Then
With Me.ListBox2
Me.ListBox2.ColumnCount = 2
Me.ListBox2.ColumnWidths = "60;60"
.AddItem
.List(i, 0) = Sheets("nauda").Range("A" & row_number)
.List(i, 1) = Sheets("nauda").Range("C" & row_number)
i = i + 1
End With
End If
Loop Until item_in_review = ""
End Sub
Display More
MODERATOR NOTE: please remember to use code tags in future as per forum rules.