- ©«¤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
        
|
¦^´_ 13# missbb
¦r¨åª«¥ó,¤]¥i¸Õ¸Õ¬Ý.- Option Explicit
- Sub Ex()
- Dim xDATE As Range, i, Rng As Range
- Dim D As Object, K, X As Long, Ar As Variant
- Set xDATE = Sheets("Attendance Report").[J3] '¿é¤J³øªíº¤é¤§«e1¤é¤é´Á ªºÀx¦s®æ
- With Sheets("data") '¸ê®Æ¤u§@ªí
- Set Rng = .[D4] '¸ê®Æ¶}¨ÏªºÀx¦s®æ
- X = 0
- Do While Rng <> ""
- Set D = CreateObject("SCRIPTING.DICTIONARY") '³]¥ßÅÜ¼Æ :¦r¨åª«¥ó
- i = 1
- Do While Rng.Offset(i - 1) = Rng 'Employee ¤W¤U¦C¬Û¦P
- With Rng.Offset(i - 1)
- If D.EXISTS(.Range("C1").Value) Then '¦pªG¦b Dictionary ª«¥ó¤¤«ü©wªºÃöÁä¦r¦s¦b¡A¶Ç¦^ True¡A
- D(.Range("C1").Value) = D(.Range("C1").Value) & "," & .Range("D1").Text
- Else
- D(.Range("C1").Value) = .Range("D1").Text
- '.Range("C1").Value ¬°¤é´ÁÈ
- End If
- End With
- i = i + 1
- Loop
- For Each K In D.KEYS 'Keys ¤èªk ¶Ç¦^¤@Ó°}¦C¡A¸Ó°}¦C¥]§t¤@Ó Dictionary ª«¥ó¤¤ªº¥þ³¡¬J¦sªºªºÃöÁä¦r¡C
- Ar = Split(D(K), ",") 'Keysªº¤º®e
- With xDATE.Offset(, K - xDATE) 'k ¬°¤é´ÁÈ
- .Parent.Cells(.Row + X + 1, "a") = Rng.Range("b1").Value
- .Parent.Cells(.Row + X + 1, "d").Resize(20) = Rng
- If UBound(Ar) = 1 Then
- .Cells(X + 3) = Ar(0)
- .Cells(X + 4) = Ar(1)
- ElseIf UBound(Ar) = 2 Then
- .Cells(X + 3) = Ar(0)
- .Cells(X + 4) = Ar(2)
- .Cells(X + 10) = Ar(1)
- ElseIf UBound(Ar) = 3 Then
- .Cells(X + 3) = Ar(0)
- .Cells(X + 4) = Ar(3)
- .Cells(X + 10) = Ar(1)
- .Cells(X + 11) = Ar(2)
- ElseIf UBound(Ar) = 4 Then
- .Cells(X + 3) = Ar(0)
- .Cells(X + 4) = Ar(4)
- .Cells(X + 10) = Ar(1)
- .Cells(X + 11) = Ar(2)
- End If
- End With
- Next
- X = X + 20
- Set Rng = Rng.Offset(i)
- Loop
- End With
- End Sub
½Æ»s¥N½X |
|