รบกวนหน่อยคะ
ปัญหาคือ Userform VBA ที่สร้างขึ้นไม่สามารถหาข้อมูลข้าม Sheet ได้
ข้อมูลที่ต้องการค้นหาอยู่ใน Sheet1 แต่ต้องการให้ Commadbutton1 เพื่อคลิก Userform1 อยู่ใน sheet3
ตัวอย่างงานตามไฟล์แนบ
Code ที่เขียนมาตามนี้ค่ะ
Private Sub cmdClear_Click()
TxtSerch = ""
Textcode = ""
Textyear = ""
Textinst = ""
Textcustomer = ""
End Sub
Private Sub CmdSerch_Click()
On Error Resume Next
Err.Clear
nRow = Sheet1.Columns(6).Find(TxtSerch.Text).Row
If Err.Number = 91 Then
Textcode.Value = "NOT FOUND DATA"
Textyear.Value = "NOT FOUND DATA"
Textinst.Value = "NOT FOUND DATA"
Textcustomer.Value = "NOT FOUND DATA"
MsgBox "Don't have this name in record"
GoTo nNext
End If
Textcode.Value = Cells(nRow, 1)
Textyear.Value = Cells(nRow, 11)
Textinst.Value = Cells(nRow, 3)
Textcustomer.Value = Cells(nRow, 5)
Cells(nRow, 1).Activate
nNext:
End Sub
Private Sub UserForm_Click()
UserForm1.Show
End Sub
ขอบคุณค่ะ