Search ออก เเต่ปัญหาติดว่าไม่ออกค่าล่าสุด
Posted: Wed Jul 18, 2018 3:17 pm
รบกวนผู้รู้ดู โค้ดให้หน่อยค่ะ
เนื่องจาก พอเวลา กด ปุ่ม Search เเล้วอยากได้ค่า ที่ออกมาล่าสุด เเต่โค้ดอันนี้ค่าที่แอดไปตอนเเรกมาเเสดงคะ
เนื่องจาก พอเวลา กด ปุ่ม Search เเล้วอยากได้ค่า ที่ออกมาล่าสุด เเต่โค้ดอันนี้ค่าที่แอดไปตอนเเรกมาเเสดงคะ
Code: Select all
Sub search_data()
Range("B15:K18").Select
Selection.ClearContents
s_data = ([C11].Value)
If (s_data = "") Then
Range("C11").Select
MsgBox "ãÊèàÅ¢ Serial No"
Else
r1 = 15
Sheets("Database").Select
ActiveSheet.Range("E:E").End(xlDown).Select
'Sheets("Database").Select
'Range("E:E").Select
'Selection.End(xlDown).Select
Rrow = Selection.Row
For x = 2 To Rrow
a1 = Cells(x, 1).Value
a2 = Cells(x, 2).Value
a3 = Cells(x, 3).Value
a4 = Cells(x, 4).Value
a5 = Cells(x, 5).Value
a6 = Cells(x, 6).Value
a7 = Cells(x, 7).Value
a8 = Cells(x, 8).Value
a9 = Cells(x, 9).Value
a10 = Cells(x, 10).Value
If (s_data = a5) Then
Sheets("Add").Select
Cells(r1, "b").Value = a1
Cells(r1, "c").Value = a2
Cells(r1, "d").Value = a3
Cells(r1, "e").Value = a4
Cells(r1, "f").Value = a5
Cells(r1, "g").Value = a6
Cells(r1, "h").Value = a7
Cells(r1, "i").Value = a8
Cells(r1, "j").Value = a9
Cells(r1, "k").Value = a10
r15 = r15 + 1
Sheets("Database").Select
End If
Next x
Sheets("Add").Select
End If
End Sub