½Ð°Ý¦p¦ó¥ÎTextbox·s¼W¸ê®Æ¨ìSheet?
- ©«¤l
- 228
- ¥DÃD
- 62
- ºëµØ
- 0
- ¿n¤À
- 364
- ÂI¦W
- 20
- §@·~¨t²Î
- Win 10
- ³nÅ骩¥»
- Office 2007 & 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2011-3-5
- ³Ì«áµn¿ý
- 2024-9-16
|
¥ý¦b¦¹·P®¦ª©¤jªºÀ°¦£...^^...
ª©¥D¤j¤j±z¦n¡G§Ú¹ï©óVBA¹ê¦b«Ü²Â©å¡A½Ð°Ý§Ú±N§Aªºµ{¦¡¶K¹L¨Ó«á¡A¬O³o¸Ì¦³°ÝÃD¶Ü?
Private Sub UserForm_Initialize()
Set DY = CreateObject("Scripting.Dictionary")
Set DZ = CreateObject("Scripting.Dictionary")
Set Sht1 = Sheets("Sheet1")
K = Sht1.[A65536].End(xlUp).Row
With Sht1
For Y = 2 To K
Ts = .Range("A" & Y): If DY(Ts) <> "" Then Else DY(Ts) = Ts: ListBox5.AddItem Ts
If .Range("D" & Y) <> "" Then TS1 = .Range("D" & Y)
If DZ(TS1) <> "" Then Else DZ(TS1) = TS1: ListBox1.AddItem TS1
Next
End With
Set DY = Nothing: Set DZ = Nothing: Y = 0: Ts = "": TS1 = "" '³o¥H¤W¬°Private Sub ListBox5_Click()©MPrivate Sub ListBox4_Click()ªºµ{¦¡
End Sub
Private Const Sh = "Sheet1" '¸ê®Æ®w '¼Ò²Õªº¨p¥Î±`¼Æ
Set d = CreateObject("Scripting.Dictionary")
With Sheets(Sh)
K = 2
Do While .Cells(K, "A") <> ""
d(.Cells(K, "A").Value) = ""
K = K + 1
Loop
End With
ListBox_1.List = d.KEYS
End Sub
Àɮצb¦¹(¤è«Kªº¸Ü½Ð±z±NÀɮקï¦n¤W¶Çµ¹§Ú¤U¸ü)¡Ghttp://www.FunP.Net/823425 |
|
|
|
|
|
|
- ©«¤l
- 5923
- ¥DÃD
- 13
- ºëµØ
- 1
- ¿n¤À
- 5986
- ÂI¦W
- 0
- §@·~¨t²Î
- win10
- ³nÅ骩¥»
- Office 2010
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW°ò¶©
- µù¥U®É¶¡
- 2010-5-1
- ³Ì«áµn¿ý
- 2022-1-23
|
¦^´_ 2# jeffrey628litw
¸Õ¸Õ¬Ý- Private Const Sh = "Sheet1" '¸ê®Æ®w '¼Ò²Õªº¨p¥Î±`¼Æ
- Dim d As Object '¼Ò²Õªº¨p¥ÎÅܼÆ
- Private Sub UserForm_Initialize()
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets(Sh)
- K = 2
- Do While .Cells(K, "A") <> ""
- d(.Cells(K, "A").Value) = ""
- K = K + 1
- Loop
- End With
- ListBox_1.List = d.KEYS
- End Sub
- Private Sub ListBox_1_Change() '»Ý×§ï ºò«æ«× ListBox±±¨î¶µ¦WºÙ
- ¸ê®Æ¨î©w 1 '©I¥sµ{¦¡ ¶Ç»¼°Ñ¼Æ : 1
- End Sub
- Private Sub ListBox_2_Change() '»Ý×§ï »sµ{ ListBox±±¨î¶µ¦WºÙ
- ¸ê®Æ¨î©w 2 '©I¥sµ{¦¡ ¶Ç»¼°Ñ¼Æ : 2
- End Sub
- Private Sub ListBox_3_Change() '»Ý×§ï ³¡ªù ListBox±±¨î¶µ¦WºÙ
- ¸ê®Æ¨î©w 3 '©I¥sµ{¦¡ ¶Ç»¼°Ñ¼Æ : 3
- End Sub
- Private Sub ListBox_4_Change() '»Ý×§ï «ù¦³ªÌ ListBox±±¨î¶µ¦WºÙ
- ¸ê®Æ¨î©w 4 '©I¥sµ{¦¡ ¶Ç»¼°Ñ¼Æ : 2
- End Sub
- Private Sub ListBox_5_Change() '»Ý×§ï ®×¥ó ListBox±±¨î¶µ¦WºÙ
- ¸ê®Æ¨î©w 5 '©I¥sµ{¦¡ ¶Ç»¼°Ñ¼Æ : 2
- End Sub
- Private Sub ¸ê®Æ¨î©w(OB As Integer)
- Dim xValue As String, i As Integer, xCellValue As String
- '***®×¥ó°ò¥»¸ê®ÆªºTextBox ½Ðקï TextBox1-TextBox9
- For i = 1 To 9
- Controls("TextBox" & i) = "" '®×¥ó°ò¥»¸ê®ÆªºTextBox±±¨î¶µ.²MªÅ
- Next
- Set d = CreateObject("Scripting.Dictionary") '«³]ª«¥ó
- For i = 1 To 5
- If i <= OB Then
- xValue = xValue & Controls("ListBox_" & i).Value 'µ²¦XListBoxªºÈ
- Else
- Controls("ListBox_" & i).Clear 'ListBox²M³æ²M°£
- End If
- Next
- With Sheets(Sh)
- K = 2
- Do While .Cells(K, "A") <> ""
- xCellValue = Application.Phonetic(.Cells(K, "A").Resize(1, OB)) 'µ²¦XÀx¦s®æªºÈ
- If OB = 5 And xValue = xCellValue Then
- For i = 1 To 9
- Controls("TextBox" & i) = .Cells(K, OB).Offset(, i) '®×¥ó°ò¥»¸ê®ÆªºTextBox±±¨î¶µ.¿é¤J¸ê®Æ
- Next
- Exit Sub
- ElseIf OB < 5 And xValue = xCellValue Then
- d(.Cells(K, OB + 1).Value) = ""
- End If
- K = K + 1
- Loop
- If OB < 5 Then Controls("ListBox_" & OB + 1).List = d.KEYS
- End With
- End Sub
½Æ»s¥N½X |
|
|
|
|
|
|
- ©«¤l
- 228
- ¥DÃD
- 62
- ºëµØ
- 0
- ¿n¤À
- 364
- ÂI¦W
- 20
- §@·~¨t²Î
- Win 10
- ³nÅ骩¥»
- Office 2007 & 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2011-3-5
- ³Ì«áµn¿ý
- 2024-9-16
|
¦U¦ì¤j®v¡A¤§«e¥i¯à¬O¤p§Ì»¡ªº¤£²M·¡¡A¤~¨S¤H¦^À³¡A¦b¦¹§Ú¦A«»¡¤@¦¸»Ý¨D¡G
ÀÉ®×1¡Ghttp://www.FunP.Net/368256
¦¹Àɪí³æUserForm1¤w§¹¦¨
ÀÉ®×2¡Ghttp://www.FunP.Net/623352
¦¹Àɪí³æUserForem2¤¤ªºListbox1-5¤]»s§@¦n¤F
»Ý¨D¬O¡G±NUserForm1ªº¥\¯à¥[¨ìUserForm2¸Ì± |
|
|
|
|
|
|