ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] 20­Ó¬Û¦P¥\¯àComboBox¦p¦ó¥i¥H¬Ù¤u¼¶¼g?

¦^´_ 20# GBKEE


    ·PÁ¶Wª©¤j¤j,¦ý¦p¦¹ªº¸Ü,·|¤Ó½ÆÂø,¦]¬°§Ú¦³«D±`¦h­Ó³£»Ý­n¤U©Ô¦¡¿ï³æ

¨C¤@­Ó¤U©Ô¦¡¿ï³æ³£­n·f°t¤@­Ótextbox ¥i¯à¼È¤£¦Ò¼{

ÁÙ¬O¥ý±Ë¥h³v¦r¿z¿ïªº¥\¯à,¦Ó¿ï¾Ü¥u¯à¥Î²Ä¤@­Ó¦r¿z¿ï¦n¤F
PKKO

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2014-12-6 13:53 ½s¿è

¦^´_ 21# PKKO

  1. Option Explicit
  2. Dim UserComboBox() As New Class1
  3. Private Sub UserForm_Initialize() 'ªí³æªì©l¤Æªº¨Æ¥ó
  4.     Dim e As Control, i As Integer
  5.     For Each e In Me.Controls
  6.         If InStr(e.Name, "ComboBox") Then
  7.             ReDim Preserve UserComboBox(0 To i)
  8.             Set UserComboBox(i).xlComBox = e
  9.             i = i + 1
  10.         End If
  11.     Next
  12. End Sub
  13. Private Sub CommandButton1_Click()
  14.     Unload Me   'Ãö³¬ªí³æ
  15. End Sub
½Æ»s¥N½X
[ Class1 ] (ª«¥óÃþ§O¼Ò²Õ)ªºµ{¦¡½X
  1. Option Explicit
  2. Public WithEvents xlComBox As MSForms.ComboBox
  3. Private Sub xlComBox_DropButtonClick()  '«ö¤UComboBox¤U©Ô½bÀY«ö¶s
  4.     Dim i As Long, S As String, Name1 As String, Arr As Variant
  5.     If xlComBox.ListIndex > -1 Then Exit Sub
  6.     'ComboBoxªº­È,¤£¦bComboBox.Listªº²M³æ¤¤¿ï¨úªº: ComBox.ListIndex=-1
  7.     S = UCase(Trim(UserForm1.TextBox1))
  8.     For i = 1 To Range("A65536").End(xlUp).Row
  9.         If UCase(Range("A" & i)) Like S & "*" And S <> "" Then
  10.             Name1 = Name1 & "," & Range("A" & i)
  11.         End If
  12.     Next
  13.     Arr = Split(Mid(Name1, 2), ",")
  14.     With xlComBox
  15.         If UBound(Arr) > -1 Then
  16.             .List = Arr
  17.             .Value = Arr(0)
  18.         Else
  19.             .Clear
  20.         End If
  21.         .DropDown
  22.     End With
  23. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 22# GBKEE

«z,¤p§Ì¨S¬Ý¹L³o­ÓªF¦è,¬ã¨s¤@¤U¥ý,·PÁ¤j¤j!
PKKO

TOP

¥»©«³Ì«á¥Ñ stillfish00 ©ó 2014-12-8 11:12 ½s¿è

¦^´_ 23# PKKO
·s¼Wª«¥óÃþ§O¼Ò²Õ clsComboBox
  1. Private WithEvents mComboBox As MSForms.ComboBox

  2. Public Sub InitialControl(ByRef oControl)
  3.   Set mComboBox = oControl
  4. End Sub

  5. Private Sub mComboBox_Change()
  6.   mComboBox.Clear
  7. End Sub

  8. Private Sub mComboBox_DropButtonClick()
  9.   Dim ar, i As Long, j As Long
  10.   ar = Application.Transpose(Range([A1], [A1].End(xlDown)))
  11.   For i = 1 To UBound(ar)
  12.     If ar(i) Like mComboBox.Text & "*" Then
  13.       j = j + 1
  14.       ar(j) = ar(i)
  15.     End If
  16.   Next
  17.   
  18.   If j > 0 Then
  19.     ReDim Preserve ar(1 To j)
  20.     mComboBox.List = ar
  21.   End If
  22. End Sub
½Æ»s¥N½X
UserForm:
  1. Private gcolComboBoxs As Collection

  2. Private Sub UserForm_Initialize()
  3.   Dim oComboBox As clsComboBox, x
  4.   
  5.   Set gcolComboBoxs = New Collection
  6.   
  7.   For Each x In Me.Controls
  8.     If StrComp(TypeName(x), "ComboBox", vbTextCompare) = 0 Then
  9.       Set oComboBox = New clsComboBox
  10.       oComboBox.InitialControl x
  11.       gcolComboBoxs.Add oComboBox
  12.     End If
  13.   Next
  14. End Sub
½Æ»s¥N½X
ªí¹F¤£²M¡BÃD·N¤£©ú½T¡B¨SªþÀɮ׮榡¡B¨S¦³°Q½×°ÝÃDªººA«×~~~~~~¥H¤W·R²ö¯à§U¡C

TOP

¦^´_ 22# GBKEE

·PÁ¶Wª©¤j¤jªº¥Î¤ß
¤p§Ì¤]·Q¨ì¤F¤@­Ó¤èªk¥i¥H¸Ñ¨M³o­Ó°ÝÃD
¨Ï¥ÎDropButtonClick´N¤£·|¦³³o­Ó°ÝÃD¤F
¤w¥i¦¨¥\¸Ñ¨M,«D±`·PÁ¶Wª©¤j¤j
PKKO

TOP

        ÀR«ä¦Û¦b : ¤£©È¨Æ¦h¡A¥u©È¦h¨Æ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD