- ©«¤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
|
¦^´_ 14# lifedidi
ªþÀɤ¤UserForm1ªºµ{¦¡½X- Private Sub UserForm_Initialize() 'ªí³æªì©l¤Æªºµ{§Ç
- Dim D As Object
- Set D = CreateObject("Scripting.Dictionary") '¦r¨åª«¥ó
- Sheet2.Range("b1").CurrentRegion.Offset(1) = "" '¥ý²M°£Â¸ê®Æ
- With Sheet1
- .AutoFilterMode = False '¨ú®ø¦Û°Ê¿z¿ï¼Ò¦¡
- For Each A In .Range(.[A2], .[A2].End(xlDown))
- D(A.Value) = ""
- Next
- ComboBox1.List = D.KEYS '±M®×¿ï¶µ¤º®e
- End With
- End Sub
- Private Sub ComboBox1_Change() '±M®×¿ï¶µ¤º®e: ¦³§ïÅÜ
- With Sheet1
- .AutoFilterMode = False
- If ComboBox1.ListIndex > -1 Then
- ComboBox2¸ê®Æ
- .Range("a1").AutoFilter 1, ComboBox1 '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä1Ä檺¿z¿ï·Ç«h¬° ComboBox1ªºÈ
- Else '§ïÅܪº¤º®e¤£¦bList¤¤
- .Range("a1").AutoFilter 1, "<>" '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä1Ä檺¿z¿ï·Ç«h¬°¤£¬OªÅ¥ÕÄæ
- ComboBox2.Clear
- End If
- ¸ê®Æ½Æ»s
- End With
- End Sub
- Private Sub ComboBox2_Change() '±M®×¿ï¶µ¤º®e: ¦³§ïÅÜ
- If ComboBox2.ListIndex > -1 Then
- Sheet1.Range("a1").AutoFilter 2, ComboBox2 '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä2Ä檺¿z¿ï·Ç«h¬° ComboBox2ªºÈ
- Else
- Sheet1.Range("a1").AutoFilter 2, "<>" '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä2Ä檺¿z¿ï·Ç«h¬°¤£¬OªÅ¥ÕÄæ
- End If
- ¸ê®Æ½Æ»s
- End Sub
- Private Sub ComboBox2¸ê®Æ()
- Dim D As Object, A
- Set D = CreateObject("Scripting.Dictionary")
- With Sheet1
- For Each A In .Range(.[A2], .[A2].End(xlDown))
- If A.Value = ComboBox1 Then D(A.Offset(, 1).Value) = ""
- Next
- If D.Count > 1 Then
- With .Columns(.Columns.Count).EntireColumn 'Sheet1ªº³Ì«á¤@Äæ
- .Clear
- .Cells(1).Resize(D.Count, 1).Value = Application.WorksheetFunction.Transpose(D.KEYS)
- '*** ±Æ§Ç
- .Cells(1).Resize(D.Count, 1).Sort Key1:=.Cells(1), Order1:=xlAscending, Header:= _
- xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
- SortMethod:=xlStroke, DataOption1:=xlSortNormal
- '*******
- ComboBox2.List = .Cells(1).Resize(D.Count, 1).Value '¤uºØ¿ï¶µ¤º®e
- .Clear
- End With
- Else
- A = D.KEYS
- ComboBox2.AddItem A(0)
- End If
- ComboBox2.Value = ComboBox2.List(0) '¤uºØ¿ï¶µªºÈ
- End With
- End Sub
- Private Sub ¸ê®Æ½Æ»s()
- Dim Rng As Range
- Sheet2.Range("b1").CurrentRegion = "" '¥ý²M°£Â¸ê®Æ
- Sheet1.Range("a1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy Sheet2.Range("b1")
- '½Æ»s:'¦Û°Ê¿z¿ï¥Xªº¸ê®Æ
- End Sub
- Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
- Sheet1.AutoFilterMode = False 'ªí³æÃö³¬«e¨ú®ø¦Û°Ê¿z¿ï¼Ò¦¡
- End Sub
½Æ»s¥N½X |
|