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

[µo°Ý] ¤U©Ô¦¡²M³æ¸Ì¿ï¾Ü"¿z¿ï¤£­«½Æªº¸ê®Æ"

¦^´_ 12# lifedidi
1¦³¿ìªk·Ó¶¶§Ç
  1. Private Sub UserForm_Initialize()  'ªí³æªì©l¤Æªºµ{§Ç
  2.     Dim D As Object
  3.     Set D = CreateObject("Scripting.Dictionary")    '¦r¨åª«¥ó
  4.     With Sheet1
  5.         For Each a In .Range(.[D7], .[D7].End(xlDown))
  6.             D(a.Value) = ""
  7.         Next
  8.     End With
  9.     ComboBox1.List = D.keys       '±M®×¿ï¶µ¤º®e
  10. End Sub
  11. Private Sub ComboBox1_Change()      '±M®×¿ï¶µ¤º®e: ¦³§ïÅÜ
  12.     If ComboBox1.ListIndex > -1 Then
  13.         ComboBox2¸ê®Æ
  14.     Else                            '§ïÅܪº¤º®e¤£¦bList¤¤
  15.         ComboBox2.Clear
  16.     End If
  17. End Sub
  18. Private Sub ComboBox2¸ê®Æ()
  19.     Dim D As Object
  20.     Set D = CreateObject("Scripting.Dictionary")
  21.     With Sheet1
  22.         For Each a In .Range(.[D7], .[D7].End(xlDown))
  23.             If a.Value = ComboBox1 Then D(a.Offset(, 3).Value) = ""    '
  24.         Next
  25.         With .Columns(.Columns.Count).EntireColumn           'Sheet1ªº³Ì«á¤@Äæ
  26.             .Clear
  27.             .Cells(1).Resize(D.Count, 1) = Application.WorksheetFunction.Transpose(D.keys)
  28.             '*** ±Æ§Ç
  29.             .Cells(1).Resize(D.Count, 1).Sort Key1:=.Cells(1), Order1:=xlAscending, Header:= _
  30.                     xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
  31.                     SortMethod:=xlStroke, DataOption1:=xlSortNormal
  32.             '*******
  33.             ComboBox2.List = .Cells(1).Resize(D.Count, 1).Value  '¤uºØ¿ï¶µ¤º®e
  34.             ComboBox2.Value = ComboBox2.List(0)                  '¤uºØ¿ï¶µªº­È
  35.             .Clear
  36.         End With
  37.     End With
  38. End Sub
½Æ»s¥N½X
2¹q¸£¤£¦Y¤O
  1. Public Sub ²M°£()
  2.     With Sheet2
  3.         '.Cells(7, 3).Resize(999 - 7 + 1, 25 - 3 + 1) = ""
  4.         .Cells(7, 3).Resize(993, 23) = ""
  5.         'For i = 7 To 999
  6.         '    For j = 3 To 25
  7.         '   Cells(i, j) = ""
  8.         '   Next
  9.         ' Next
  10.     End With
  11. End Sub
½Æ»s¥N½X

TOP

¦^´_ 14# lifedidi
ªþÀɤ¤UserForm1ªºµ{¦¡½X
  1. Private Sub UserForm_Initialize()                   'ªí³æªì©l¤Æªºµ{§Ç
  2.     Dim D As Object
  3.     Set D = CreateObject("Scripting.Dictionary")    '¦r¨åª«¥ó
  4.     Sheet2.Range("b1").CurrentRegion.Offset(1) = "" '¥ý²M°£Â¸ê®Æ
  5.     With Sheet1
  6.         .AutoFilterMode = False                     '¨ú®ø¦Û°Ê¿z¿ï¼Ò¦¡
  7.         For Each A In .Range(.[A2], .[A2].End(xlDown))
  8.             D(A.Value) = ""
  9.         Next
  10.         ComboBox1.List = D.KEYS                     '±M®×¿ï¶µ¤º®e
  11.     End With
  12. End Sub
  13. Private Sub ComboBox1_Change()                      '±M®×¿ï¶µ¤º®e: ¦³§ïÅÜ
  14.      With Sheet1
  15.         .AutoFilterMode = False
  16.         If ComboBox1.ListIndex > -1 Then
  17.             ComboBox2¸ê®Æ
  18.             .Range("a1").AutoFilter 1, ComboBox1    '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä1Ä檺¿z¿ï·Ç«h¬° ComboBox1ªº­È
  19.         Else                                        '§ïÅܪº¤º®e¤£¦bList¤¤
  20.             .Range("a1").AutoFilter 1, "<>"         '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä1Ä檺¿z¿ï·Ç«h¬°¤£¬OªÅ¥ÕÄæ
  21.             ComboBox2.Clear
  22.         End If
  23.         ¸ê®Æ½Æ»s
  24.     End With
  25. End Sub
  26. Private Sub ComboBox2_Change()                      '±M®×¿ï¶µ¤º®e: ¦³§ïÅÜ
  27.     If ComboBox2.ListIndex > -1 Then
  28.         Sheet1.Range("a1").AutoFilter 2, ComboBox2  '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä2Ä檺¿z¿ï·Ç«h¬° ComboBox2ªº­È
  29.     Else
  30.         Sheet1.Range("a1").AutoFilter 2, "<>"       '¦Û°Ê¿z¿ï¼Ò¦¡:²Ä2Ä檺¿z¿ï·Ç«h¬°¤£¬OªÅ¥ÕÄæ
  31.     End If
  32.     ¸ê®Æ½Æ»s
  33. End Sub
  34. Private Sub ComboBox2¸ê®Æ()
  35.     Dim D As Object, A
  36.     Set D = CreateObject("Scripting.Dictionary")
  37.     With Sheet1
  38.         For Each A In .Range(.[A2], .[A2].End(xlDown))
  39.             If A.Value = ComboBox1 Then D(A.Offset(, 1).Value) = ""
  40.         Next
  41.         If D.Count > 1 Then
  42.             With .Columns(.Columns.Count).EntireColumn           'Sheet1ªº³Ì«á¤@Äæ
  43.                 .Clear
  44.                 .Cells(1).Resize(D.Count, 1).Value = Application.WorksheetFunction.Transpose(D.KEYS)
  45.                 '*** ±Æ§Ç
  46.                 .Cells(1).Resize(D.Count, 1).Sort Key1:=.Cells(1), Order1:=xlAscending, Header:= _
  47.                     xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
  48.                     SortMethod:=xlStroke, DataOption1:=xlSortNormal
  49.                 '*******
  50.                 ComboBox2.List = .Cells(1).Resize(D.Count, 1).Value  '¤uºØ¿ï¶µ¤º®e
  51.                 .Clear
  52.             End With
  53.         Else
  54.             A = D.KEYS
  55.             ComboBox2.AddItem A(0)
  56.         End If
  57.             ComboBox2.Value = ComboBox2.List(0)                  '¤uºØ¿ï¶µªº­È
  58.     End With
  59. End Sub
  60. Private Sub ¸ê®Æ½Æ»s()
  61.     Dim Rng As Range
  62.     Sheet2.Range("b1").CurrentRegion = ""             '¥ý²M°£Â¸ê®Æ
  63.     Sheet1.Range("a1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy Sheet2.Range("b1")
  64.     '½Æ»s:'¦Û°Ê¿z¿ï¥Xªº¸ê®Æ
  65. End Sub
  66. Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
  67.     Sheet1.AutoFilterMode = False      'ªí³æÃö³¬«e¨ú®ø¦Û°Ê¿z¿ï¼Ò¦¡
  68. End Sub
½Æ»s¥N½X

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-3-12 08:49 ½s¿è

¦^´_ 16# lifedidi
  1. Dim ¸ê®Æªí As Worksheet  '***³]©w¸ê®Æ¤u§@ªí ¨Ñªí³æ¤¤ªºµ{§Ç¦@¦P¨Ï¥Î ***
  2. Dim ¬d¸ßªí As Worksheet  '***³]©w¸ê®Æ¤u§@ªí ¨Ñªí³æ¤¤ªºµ{§Ç¦@¦P¨Ï¥Î ***
  3. Private Sub UserForm_Initialize()  'ªí³æªì©l¤Æªºµ{§Ç
  4.     Dim D As Object
  5.     Set D = CreateObject("Scripting.Dictionary")    '¦r¨åª«¥ó
  6.     Set ¸ê®Æªí = Sheet1      ' ¸ê®Æ¤u§@ªí ©Î ¬d¸ß¤u§@ªí ªº¤u§@ªí ¦p¦³ÅÜ°Ê®É
  7.     Set ¬d¸ßªí = Sheet2      ' ¦b¦¹­×§ï:¤£¥²¥h©Ò¦³µ{¦¡½X¤¤¤@¤@­×§ï¤u§@ªí¦WºÙ
  8.     With ¸ê®Æªí
  9.         .AutoFilterMode = False
  10.         For Each a In .Range(.[A2], .[A2].End(xlDown))
  11.             D(a.Value) = ""
  12.         Next
  13.     End With
  14.     ComboBox1.List = D.keys       '±M®×¿ï¶µ¤º®e
  15. End Sub
  16. Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
  17.         'ªí³æÃö³¬ªºµ{§Ç
  18.         ¸ê®Æªí.AutoFilterMode = False                             '¨ú®ø¦Û°Ê¿z¿ï
  19.         ¬d¸ßªí.UsedRange.Offset(1) = ""
  20. End Sub
  21. Private Sub CommandButton1_Click()
  22.     '*** UserForm2 ªºListBox1 §ï¦¨ TextBox ±±¨î¶µ             *****
  23.     With UserForm2
  24.         .TextBox1 = Application.Text(Application.Sum(¬d¸ßªí.[D:D]), "[hh]:mm")
  25.         .Show 0
  26.     End With
  27. End Sub
  28. Private Sub ComboBox1_Change()      '±M®×¿ï¶µ¤º®e: ¦³§ïÅÜ
  29.     If ComboBox1.ListIndex > -1 Then
  30.         ComboBox2¸ê®Æ
  31.     Else                            '§ïÅܪº¤º®e¤£¦bList¤¤
  32.         ComboBox2.Clear
  33.     End If
  34.     Show_¸ê®Æ
  35. End Sub
  36. Private Sub ComboBox2_Change()      '±M®×¿ï¶µ¤º®e: ¦³§ïÅÜ
  37.     Show_¸ê®Æ
  38. End Sub
  39. Private Sub ComboBox2¸ê®Æ()
  40.     Dim D As Object
  41.     Set D = CreateObject("Scripting.Dictionary")
  42.     With ¸ê®Æªí
  43.         .AutoFilterMode = False
  44.         For Each a In .Range(.[A2], .[A2].End(xlDown))
  45.             If a.Value = ComboBox1 Then D(a.Offset(, 1).Value) = ""    '
  46.         Next
  47.         With .Columns(.Columns.Count).EntireColumn           'Sheet1ªº³Ì«á¤@Äæ
  48.             .Clear
  49.             .Cells(1).Resize(D.Count, 1) = Application.WorksheetFunction.Transpose(D.keys)
  50.             '*** ±Æ§Ç
  51.             .Cells(1).Resize(D.Count, 1).Sort Key1:=.Cells(1), Order1:=xlAscending, Header:= _
  52.                     xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
  53.                     SortMethod:=xlStroke, DataOption1:=xlSortNormal
  54.             '*******
  55.             ComboBox2.List = .Cells(1).Resize(D.Count, 1).Value  '¤uºØ¿ï¶µ¤º®e
  56.             ComboBox2.Value = ComboBox2.List(0)                  '¤uºØ¿ï¶µªº­È
  57.             .Clear
  58.         End With
  59.     End With
  60. End Sub
  61. Private Sub Show_¸ê®Æ()
  62.     UserForm2.TextBox1 = ""
  63.     With ¸ê®Æªí
  64.         .AutoFilterMode = False                             '¨ú®ø¦Û°Ê¿z¿ï
  65.         If ComboBox1.ListIndex > -1 Then
  66.             .Range("A1").AutoFilter 1, ComboBox1            '¦Û°Ê¿z¿ï: ²Ä¤@Äæ(AÄæ)ªº·Ç«h ¬° ComboBox1
  67.             If ComboBox2.ListIndex > -1 Then
  68.                 .Range("A1").AutoFilter 2, ComboBox2        '¦Û°Ê¿z¿ï: ²Ä¤@Äæ(AÄæ)ªº·Ç«h ¬° ComboBox12
  69.             End If
  70.         End If
  71.         .UsedRange.Range("A:C").Copy ¬d¸ßªí.[B1]            '¸ê®Æªí:¦Û°Ê¿z¿ï¥Xªº¸ê®Æ ½Æ»s¨ì ¬d¸ßªí
  72.     End With
  73. End Sub
½Æ»s¥N½X

TOP

¦^´_ 18# lifedidi
¥d¦b²Ä71¦C ¥i¯à¬O2007 ¤£±µ¨ü³o¼gªk ½Ð­×§ï¦p¤U
  1. Private Sub ComboBox2¸ê®Æ()  'ComboBox1¦³²§°Ê:´M§ä [¤uºØ]Äæ¦ìªº¦r¦ê
  2.     Dim D As Object
  3.     Set D = CreateObject("Scripting.Dictionary")
  4.     With ¸ê®Æªí
  5.         .AutoFilterMode = False
  6.         For Each a In .Range(.[A2], .[A2].End(xlDown))
  7.             
  8.             If a.Value = ComboBox1 Then D(a.Offset(, 1).Value) = ""
  9.             '²Å¦XComboBox1 ªº [¤uºØ]¤¤-> ¦r¨åª«¥ó:D(Key) -> D(¤uºØªº¦r¦ê)
  10.         Next
  11.        '** ¥H¤Uµ{¦¡½X±N ¦r¨åª«¥ó:D(Key)ªº¦r¦ê½Æ»s¦b³Ì«á¤@Äæ
  12.        '** ¤§«á¥[¥H±Æ§ÇµM«á³]¬° ComboBox2.List
  13.        With .Columns(.Columns.Count).EntireColumn           'Sheet1ªº³Ì«á¤@Äæ
  14.             .Clear
  15.             .Cells(1).Resize(D.Count, 1) = Application.WorksheetFunction.Transpose(D.keys)
  16.             '*** ±Æ§Ç
  17.             .Cells(1).Resize(D.Count, 1).Sort Key1:=.Cells(1), Order1:=xlAscending, Header:= _
  18.                     xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
  19.                     SortMethod:=xlStroke, DataOption1:=xlSortNormal
  20.             '*******
  21.             ComboBox2.List = .Cells(1).Resize(D.Count, 1).Value  '¤uºØ¿ï¶µ¤º®e
  22.             ComboBox2.Value = ComboBox2.List(0)                  '¤uºØ¿ï¶µªº­È
  23.             '**
  24.         End With
  25.     End With
  26. End Sub
  27. Private Sub Show_¸ê®Æ()    '** ¸ê®Æªí¤¤ ¦Û°Ê¿z¿ï
  28.     With ¸ê®Æªí
  29.         .AutoFilterMode = False        '¨ú®ø¦Û°Ê¿z¿ï-> ¸ê®Æ¥þ³¡Åã¥Ü¥X¨Ó:·s¿z¿ï«áªº¸ê®Æ¤~·|¥¿½T
  30.         If ComboBox1.ListIndex > -1 Then
  31.             .Range("A1").AutoFilter 1, ComboBox1            '¦Û°Ê¿z¿ï: ²Ä¤@Äæ(AÄæ)ªº·Ç«h ¬° ComboBox1
  32.             If ComboBox2.ListIndex > -1 Then
  33.                 .Range("A1").AutoFilter 2, ComboBox2        '¦Û°Ê¿z¿ï: ²Ä¤@Äæ(AÄæ)ªº·Ç«h ¬° ComboBox12
  34.             End If
  35.         End If
  36.         '.UsedRange.Range("A:C").Copy ¬d¸ßªí.[B1]
  37.         .Range("A:C").Copy ¬d¸ßªí.[B1]                       '¸ê®Æªí:¦Û°Ê¿z¿ï¥Xªº¸ê®Æ ½Æ»s¨ì ¬d¸ßªí
  38.     End With
  39. End Sub
½Æ»s¥N½X

.Range("A1").AutoFilter 1, ComboBox1   ¦p¹Ï


TOP

¦^´_ 20# lifedidi
½Ð¦bªþ¤WÀÉ®× ¬Ý¬Ý

TOP

¦^´_ 22# lifedidi
¦Û°Ê ©Î ¶i¶¥ ¿z¿ï ¸ê®Æ®wªºªíÀY ³£¤£¾A©y¦³¦X¨ÖªºÀx¦s®æ
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 25# lifedidi
  1. Sub Ex()
  2.     Dim a
  3.     With [a1] '¤£²M·¡ With ????
  4.        ' .Parent (¤W¤@¼hªºª«¥ó): ¤u§@ªí
  5.         If .Parent.AutoFilterMode = False Then .AutoFilter
  6.         .AutoFilter Field:=2, Criteria1:=ComboBox1
  7.         'For Each a In .Columns(2).Cells.SpecialCells(12)
  8.         '¤W­± For ³o¸Ì¦³¿ù»~:ª½±µ¸õ¨ì Next ¤£·|°õ¦æ¦^°é
  9.         '¦p¬O With ' [a1]->Àx¦s®æ½d³ò ¶·§ï¦¨¦p¤U
  10.         For Each a In .Parent.Columns(2).Cells.SpecialCells(xlCellTypeVisible)
  11.             If a <> "" Then
  12.                 d(a.Value) = ""
  13.             Else
  14.                 Exit For
  15.             End If
  16.         Next
  17.     End With
  18. End Sub
½Æ»s¥N½X
  1. SpecialCells ¤èªk ¶Ç¦^ Range ª«¥ó¡A¦¹ª«¥ó¥Nªí»P«ü©w«¬ºA¤Î­È¬Û²Å¦Xªº©Ò¦³Àx¦s®æ¡CRange ª«¥ó¡C
  2. expression.SpecialCells(Type, Value)
  3. expression      ¥²¿ï¡C¸Ó¹Bºâ¦¡·|¶Ç¦^ [®M¥Î©ó] ²M³æ¤¤ªº¨ä¤¤¤@­Óª«¥ó¡C
  4. Type     ¥²¿ïªº XlCellType¡C­n¥]§tªºÀx¦s®æ¡C
  5. XlCellType ¥i¥H¬O³o¨Ç XlCellType ±`¼Æ¤§¤@¡C
  6. xlCellTypeAllFormatConditions¡C  ¥ô¦ó®æ¦¡ªºÀx¦s®æ
  7. xlCellTypeAllValidation¡C¨ã¦³ÅçÃÒ·Ç«hªºÀx¦s®æ
  8. xlCellTypeBlanks¡CªÅÀx¦s®æ
  9. xlCellTypeComments¡C¥]§tµù¸ÑªºÀx¦s®æ
  10. xlCellTypeConstants¡C¥]§t±`¼ÆªºÀx¦s®æ
  11. xlCellTypeFormulas¡C¥]§t¤½¦¡ªºÀx¦s®æ
  12. xlCellTypeLastCell¡C¤w¥Î½d³òªº³Ì«á¤@­ÓÀx¦s®æ
  13. xlCellTypeSameFormatConditions¡C  ¦³¬Û¦P®æ¦¡ªºÀx¦s®æ
  14. xlCellTypeSameValidation¡C  ¦³¬Û¦PÅçÃÒ·Ç«hªºÀx¦s®æ
  15. xlCellTypeVisible¡C©Ò¦³¥i¨£Àx¦s®æ
½Æ»s¥N½X


·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 28# lifedidi
  1. Option Explicit
  2. Private Sub UserForm_Initialize()
  3.     Dim A As Date
  4.     TextBox1.Value = "8:00"
  5.     TextBox2.Value = "12:00"
  6.     TextBox3 = Val(TextBox2) - Val(TextBox1)
  7.     'TextBox3 = Format(CDate(TextBox2) - CDate(TextBox1), "H:M")
  8.     'A = CDate(TextBox2) - CDate(TextBox1)
  9.     'TextBox3 = A
  10. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 30# lifedidi
  1. Option Explicit
  2. Private Sub TextBox1_Change()
  3.     ­p®É
  4. End Sub
  5. Private Sub TextBox2_Change()
  6.     ­p®É
  7. End Sub
  8. Private Sub ­p®É()
  9.     'TextBox3±±¨î¶µ ½Ð§ï¦¨Label±±¨î¶µ¬°¨Î
  10.     If IsDate(TextBox1) And IsDate(TextBox2) Then
  11.         TextBox3 = Format(CDate(TextBox2) - CDate(TextBox1), "HH:MM")
  12.         'Label1.Caption = Format(CDate(TextBox2) - CDate(TextBox1), "HH:MM")
  13.     Else
  14.         TextBox3 = ""
  15.       '  Label1.Caption = ""
  16.     End If
  17. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¡i¬O§_µo´§¤F¨}¯à¡H¡j¤H¶¡¹Ø©R¦]¬°µu¼È¡A¤~§óÅã±o¬Ã¶Q¡CÃø±o¨Ó¤@½ë¤H¶¡¡AÀ³°Ý¬O§_¬°¤H¶¡µo´§¤F¦Û¤vªº¨}¯à¡A¦Ó¤£­n¤@¨ý¨Dªø¹Ø¡C
ªð¦^¦Cªí ¤W¤@¥DÃD