snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
Private Sub ComboBox1_Change()
Dim a
a = Filter(Application.Transpose(Sheets("Province").[B2:B7538]), ComboBox1.Value)
If UBound(a) > 0 Then
Sheets("Province").[I2:I7538] = Application.Transpose(a)
ComboBox1.ListFillRange = "DropDownList"
Else
ComboBox1.ListFillRange = ""
End If
Me.ComboBox1.DropDown
End Sub
Range name
DropDownList
=Province!$I$2:INDEX(Province!$I$2:$I$7537,MATCH("ๆ",Province!$I$2:$I$7538))
You do not have the required permissions to view the files attached to this post.
Private Sub ComboBox1_Change()
Dim i As Long
With Me.ComboBox1
If Not IsArrow Then .List = Range("customerlist").Value 'ติดบรรทัดนี้ครับ
If .ListIndex = -1 And Len(.Text) Then
For i = .ListCount - 1 To 0 Step -1
If InStr(1, .List(i), .Text, 1) = 0 Then .RemoveItem i
Next i
.DropDown
End If
End With
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
IsArrow = KeyCode = vbKeyUp Or KeyCode = vbKeyDown
If KeyCode = vbKeyReturn Then Me.ComboBox1.List = Range("customerlist").Value
End Sub
ต้องปรับอย่างไรบ้างครับ
You do not have the required permissions to view the files attached to this post.
Dim custList As Range
Dim IsArrow As Boolean
Private Sub ComboBox1_Change()
Dim i As Long
With Sheets("Customers")
Set custList = .Range("d3", .Range("d" & .Rows.Count).End(xlUp))
End With
If Not IsArrow Then
With Me.ComboBox1
.List = custList.Value
.ListRows = Application.WorksheetFunction.Min(custList.Count, .ListCount)
.DropDown
If Len(.Text) Then
For i = .ListCount - 1 To 0 Step -1
If InStr(1, .List(i), .Text, 1) = 0 Then .RemoveItem i
Next i
.DropDown
End If
End With
End If
End Sub
Private Sub ComboBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, _
ByVal Shift As Integer)
IsArrow = (KeyCode = vbKeyUp) Or (KeyCode = vbKeyDown)
If KeyCode = vbKeyReturn Then Me.ComboBox1.List = custList.Value
End Sub