Page 1 of 1

Findหาข้อมูลให้ขึ้นในListbox แต่ข้อมูลขึ้นไม่ครบครับ

Posted: Thu Mar 08, 2018 6:17 pm
by Konggetamped
ผมมีข้อมูลสินค้าอยู่1000กว่ารายการ ต้องการทำform สำหรับแสดงรายละเอียดสินค้าและแสดงภาพ
ตอนนี้ ผมจะทำให้คำKeyword ที่ต้องการค้นหา พอกดปุ่มenter แล้วมีชื่อสินค้าที่ตรงหรือมีคำkeyword อยู่ในชื่อยาวๆ ขึ้นในListbox
ตามโค้ดที่ผมทำมา มีผลลัพท์คือบางคำก็เจอ บางคำก็ไม่เจอ บางคำเจอแต่ขึ้นแค่ตัวที่เจอตัวแรกครับ

Code: Select all

Private Sub btnSname_Click()
Dim intCount As Integer
Dim intType As Integer
Dim intList As Integer
Dim intTotal As Integer
Dim ws As Workbook

intList = 2
intItem = 2

For intType = 1 To 12
If Cells(1, intType).Value = cbbType.Text Then
Exit For
End If
Next

If txtKey.Text = "" Then
 strValueMsg = MsgBox("Please Enter Keyword", 1, "Foodscan Application")
 Else
    For intCount = 2 To 1500
    If Cells(intCount, intType).Value = Sheet2.Cells.Find(txtKey.Value, LookIn:=xlFormulas, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext) Then
    test.AddItem (Sheet2.Cells(intCount, 4))
    End If
     Next

End If



End Sub

Re: Findหาข้อมูลให้ขึ้นในListbox แต่ข้อมูลขึ้นไม่ครบครับ

Posted: Thu Mar 08, 2018 7:36 pm
by snasui
:D กรุณาแนบไฟล์ตัวอย่างข้อมูลพร้อม Code ชี้ให้เห็นว่าข้อมูลที่ได้เป็นอย่างไร ที่ถูกควรเป็นอย่างไร จะได้สะดวกกับเพื่อนสมาชิกในการตอบครับ