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

[µo°Ý] ¦bvba userform ³]3­Ó combox3 ¦p¦ó3¼h¿z¿ï

[µo°Ý] ¦bvba userform ³]3­Ó combox3 ¦p¦ó3¼h¿z¿ï

[ª©¥DºÞ²z¯d¨¥]
  • Hsieh(2011-10-28 08:12): ½Ð¤W¶ÇÀÉ®×

¦bvba userform ³]3­Ó combox3
¸ê®Æ¨Ó·½ EXCEL SHEET1 ¤ÀÃþ:AÄæ ¤j¶µ BÄæ ¤p¶µCÄæ ²Ó¶µ  DÄæ ©Ò­nªº­È
³o¶W­Ó1¼h­n¦p¦ó¼g,½Ð±Ð¦U¦ì¥ý¶i,ÁÂÁÂ!
max

¦^´_ 1# user999 ¦A
¦A³Â·Ð±z¬Ý¬Ý §ÚÁÙ¨SÅv­­ ¤U¸ü

testa.rar (11.02 KB)

¦p¦ó3¼h¿z¿ï

max

TOP

userform¤¤¡G
  1. Private Sub ComboBox1_Change()
  2. With ComboBox2
  3. If InStr(d(ComboBox1.Value), ",") = 0 Then
  4. .Clear
  5.         .AddItem d(ComboBox1.Value)
  6.         Else
  7. .List = Split(d(ComboBox1.Value), ",")
  8. End If
  9. End With
  10. End Sub

  11.          
  12. Private Sub ComboBox2_Change()
  13. With ComboBox3
  14. If InStr(d2(ComboBox1.Value & ComboBox2.Value), ",") = 0 Then
  15. .Clear
  16.         .AddItem d2(ComboBox1.Value & ComboBox2.Value)
  17.         Else
  18. .List = Split(d2(ComboBox1.Value & ComboBox2.Value), ",")
  19. End If
  20. End With

  21. End Sub

  22. Private Sub ComboBox3_Change()
  23. With Sheet1
  24. rng = .UsedRange
  25. For i = 2 To UBound(rng)
  26. If rng(i, 1) & rng(i, 2) & rng(i, 3) = ComboBox1.Value & ComboBox2.Value & ComboBox3.Value Then
  27. x = x + rng(i, 4)
  28. End If
  29. Next
  30. TextBox1.Value = x
  31. End With
  32. End Sub

  33. Private Sub UserForm_Initialize()
  34. Set d = CreateObject("Scripting.Dictionary")
  35. Set d2 = CreateObject("Scripting.Dictionary")
  36. With Sheet1
  37. rng = .UsedRange
  38. For i = 2 To UBound(rng)
  39. If d(rng(i, 1)) = "" Then
  40. d(rng(i, 1)) = rng(i, 2)
  41. Else
  42. If InStr(d(rng(i, 1)), rng(i, 2)) = 0 Then
  43. d(rng(i, 1)) = d(rng(i, 1)) & "," & rng(i, 2)
  44. End If
  45. End If
  46. If d2(rng(i, 1) & rng(i, 2)) = "" Then
  47. d2(rng(i, 1) & rng(i, 2)) = rng(i, 3)
  48. Else
  49. If InStr(d2(rng(i, 1) & rng(i, 2)), rng(i, 3)) = 0 Then
  50. d2(rng(i, 1) & rng(i, 2)) = d2(rng(i, 1) & rng(i, 2)) & "," & rng(i, 3)
  51. End If
  52. End If
  53. Next
  54. ComboBox1.List = d.keys
  55. End With
  56. End Sub
½Æ»s¥N½X
Module¤¤
  1. Public d As Object
  2. Public d2 As Object
½Æ»s¥N½X

TOP

¦^´_ 2# user999
UserForm ªºµ{¦¡½X
  1. Dim D As Object
  2. Private Sub UserForm_Initialize()
  3.     Dim Dx(1 To 3) As Object, i As Integer, ii As Integer
  4.     Set D = CreateObject("SCRIPTING.DICTIONARY")
  5.     For ii = 1 To UBound(Dx)
  6.         Set Dx(ii) = CreateObject("SCRIPTING.DICTIONARY")
  7.     Next
  8.     i = 2
  9.     Do While Sheet1.Cells(i, 1) <> ""
  10.            For ii = 1 To UBound(Dx)
  11.                 Dx(ii)(Cells(i, ii).Value) = ""
  12.             Next
  13.             D(Cells(i, 1) & Cells(i, 2) & Cells(i, 3)) = Cells(i, "d")
  14.             i = i + 1
  15.     Loop
  16.     For ii = 1 To UBound(Dx)
  17.         Controls("ComboBox" & ii).List = Dx(ii).keys
  18.     Next
  19. End Sub
  20. Private Sub ComboBox1_Change()
  21.     ¥­§¡
  22. End Sub
  23. Private Sub ComboBox2_Change()
  24.     ¥­§¡
  25. End Sub
  26. Private Sub ComboBox3_Change()
  27.     ¥­§¡
  28. End Sub
  29. Private Sub ¥­§¡()
  30.     If D.exists(ComboBox1 & ComboBox2 & ComboBox3) Then
  31.         TextBox1 = D(ComboBox1 & ComboBox2 & ComboBox3)
  32.     Else
  33.         TextBox1 = ""
  34.     End If
  35. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# oobird


    ¤Ó·PÁ±z­Ì¤F!§Ú¸Ó¦n¦n¾Ç²ß,¥H±z­Ì¬°º]¼Ë,¼ö¤ß±M·~,ÁÂÁÂ!
max

TOP

¦^´_ 4# GBKEE


     ¤Ó·PÁ±z­Ì¤F!§Ú¸Ó¦n¦n¾Ç²ß,¥H±z­Ì¬°º]¼Ë,¼ö¤ß±M·~,ÁÂÁÂ!
max

TOP

        ÀR«ä¦Û¦b : §g¤l¬°¥Ø¼Ð¡A¤p¤H¬°¥Øªº¡C
ªð¦^¦Cªí ¤W¤@¥DÃD