จะรบกวนเพิ่มเติมค่ะ
พอดีต้องการให้เมื่อมีการเปลี่ยนแปลงที่อยู่ ในช่อง แขวง/ตำบล แล้วขึ้น อำเภอ จังหวัด รหัสไปรษณีย์ อัตโนมัติ เลยใช้ Fucntion Vlookup
แต่ติด Error ค่ะ ต้องปรับโค้ดยังไงคะ
Code: Select all
Private Sub listtambon1_Change()
Me.listampor1 = Application.VLookup(listtambon1.Value, Worksheets("Address").Range("D3:G7428"), 2, 0)
End Sub
[/quote]
ปรับตามนี้ครับ
Code: Select all
Private Sub listtambon1_Change()
On Error Resume Next
Me.listampor1 = Application.VLookup(listtambon1.Value, Worksheets("Address").Range("C3:G7428"), 2, 0)
Me.listprovince1 = Application.VLookup(listtambon1.Value, Worksheets("Address").Range("C3:G7428"), 3, 0)
Me.Txtcode1 = Application.VLookup(listtambon1.Value, Worksheets("Address").Range("C3:G7428"), 4, 0)
End Sub
[/quote]
ขอบคุณมากนะคะ รบกวนช่วยแนะนำเพิ่มเติมด้วยค่ะ ไม่ต้องการให้ในช่อง เขต/อำเภอ โชว์ข้อมูลเหมือนกัน จากไฟล์ Sheet Address มีเขตบางมด 2 ที่ แต่คนล่ะเขตกัน แต่จากรูปโชว์เป็น เขตเดียวกัน
)
Code: Select all
Private Sub listtambon1_Change()
On Error Resume Next
Dim Amphur1 As Range
Dim iStart As Integer
Dim iStop As Integer
With Sheets("Address")
iStart = Application.Match(listtambon1, .Range("C:C"), 0)
iStop = Application.CountIf(.Range("C:C"), listtambon1)
Set Amphur1 = .Range("D" & iStart).Resize(iStop)
End With
listampor1 = ""
listprovince1 = ""
Txtcode1 = ""
listampor1.RowSource = "Address!" & Amphur1.Address
End Sub
Private Sub Userform_Activate()
On Error Resume Next
Dim tambon1 As String
tambon1 = Range("C3:f7428").Address
listtambon1.RowSource = "Address!" & tambon1
End Sub
You do not have the required permissions to view the files attached to this post.