- ©«¤l
- 1447
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1471
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-11-29
|
¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-1-19 16:33 ½s¿è
¦^´_ 31# ã´£³¡ªL
ÁÂÁ«e½ú«ü¾É
«á¾Ç¾q¶w! ¾Ç²ß±zªº½d¨Ò¯uªº«ÜÃø!
µù¸Ñ¤ß±o¦b«e½úªºµ{¦¡¤W!
¦p¦³«_¥Ç½Ð¨£½Ì!¤]½Ð«e½ú¦A«ü¾É!
±Ð®v¸`§Ö¼Ö!
Xl0000108_TESTv01_20240117_4.zip (530.58 KB)
Sub CB2_Click()
Application.ScreenUpdating = False
With Sheets("ªí³æ")
.[A:I].UnMerge
.[C1] = "XXX¤½¥q"
.[C2] = "±M¯S®×©ú²Óªí"
.UsedRange.Offset(4, 0).EntireRow.Delete
'¡ô1.(¥þ³¡¦³¨Ï¥ÎªºÀx¦s®æ½d³ò°¾²¾¤U¤è4¦C)§R°£
'¡ô2.°¾²¾¤U¤è4¦C·|®Ø¨ì¨S¦³¨Ï¥Î¨ìªº4¦CÀx¦s®æ!§R°£¤£¼vÅTµ²ªG!
.ResetAllPageBreaks '«³]¤À¶½u
End With
Dim Arr, Brr(1 To 999, 1 To 9), Crr, xD, i&, j%, T1$, T2$, T3$, T4$, T5$, TT$, R&, N&, xA As Range
tm = Timer
Set xD = CreateObject("Scripting.Dictionary")
Arr = Range([Á`ªí!AM2], [Á`ªí!A1].Cells(Rows.Count, 1).End(3))
For i = 2 To UBound(Arr)
T1 = Arr(i, 9) '±M¯S®×¸¹ Äæ
T2 = Arr(i, 12) '½ÐÁʮ׸¹ Äæ
T3 = Arr(i, 21) '±M®×¹wºâ Äæ
T4 = Arr(i, 23) '¤wµ¹¥Iª÷ÃB Äæ
T5 = Arr(i, 25) 'ª¬ºA Äæ
TT = T2 & "|" & T4 '½ÐÁʮ׸¹ "|" ¤wµ¹¥Iª÷ÃB
If T1 = "" Or T2 = "µL" Or T3 = "" Or xD(TT) > 0 Then
'¡ô·íi = 2:xD(TT) > 0 ¬O¥Î¨ÓÀË´ú¬O§_¦³(½ÐÁʮ׸¹|¤wµ¹¥Iª÷ÃB)«½Æ__±Æ°£«ÂÐ
GoTo i01
End If
Crr = xD(T1 & "/c")
'¡ô·íi = 2:¥ý¥OCrr=¦r¨å¸Ìªº ±M¯S®×¸¹+"/c" (¥["/c"¦r¤¸¨¾Part)
'¡ô·íi = 2:Crr¬OªÅªº! ¦]Crr¤@¶}©l¬OªÅªº,xD("A2009001/c")¦r¨å¸Ì¤]§ä¤£¨ì!
'¡ô·íi >= 3:Crr¤w¸g¬O°}¦C¤F ¦]1.xD(T1 & "/c") = Crr ,2.¤u§@ªí²Ä3,4¦C±M¯S®×¸¹³£¬OA2009001
'¡ôª½¨ìi = 50:¤]¬O¤u§@ªí²Ä51¦C ±M¯S®×¸¹=A2104001,xD("A2104001/c")¦b¦r¨å¸Ì¬O§ä¤£¨ìªº
xD(TT) = 1
'¡ô·íi = 2:½ÐÁʮ׸¹|¤wµ¹¥Iª÷ÃB ˤJ¦r¨å¸Ì,item=1,Åýi>=3 ®É±Æ°£«½Æ
'¡ô·íi = 3:½ÐÁʮ׸¹|¤wµ¹¥Iª÷ÃB ˤJ¦r¨å¸Ì,item=1,Åýi>=4 ®É±Æ°£«½Æ
'¡ô·íi > 3:Ä~ÄòˤJ,Åý«e±±Æ°£«½Æ
xD(T1) = xD(T1) + 1
'¡ô·íi = 2:¤@¶}©l±N ²Ä¤@ºØ ±M¯S®×¸¹(.KEY) ˤJ¦r¨å.ITEM = 1
',ITEM¤]¬O«á±n©ñ¤JCrrªº¦C¸¹1
'¡ô·íi = 3:±M¯S®×¸¹(.KEY) ¦r¨å¤w¸g¦³¤F.©Ò¥HITEM = 2
' ,ITEM¤]¬O«á±n©ñ¤JCrrªº¦C¸¹2,«á±Ä~ÄòˤJ
'¡ôª½¨ìi = 50:²Ä¤GºØ ±M¯S®×¸¹ ˤJ¦r¨å.ITEM = 1,«á±Ä~ÄòˤJ
'¡ô¤Sª½¨ìi = 59:±M¯S®×¸¹¦P²Ä¤@ºØ,²Ä¤@ºØ±M¯S®×¸¹ITEM¦A¥[ 1
If Not IsArray(Crr) Then '§P©wCrr¬O¤£¬O°}¦C
'¡ô·íi = 2:¤@¶}©lCrr¤£¬O°}¦C!¥u¬OªÅªº
'¡ô·íi >= 3:Crr¬O°}¦C¤F!±ø¥ó¤£¦¨¥ß,´N¸õ¨ì End If
'¡ôª½¨ìi = 50:Crr¤S¤£¬O°}¦C!¤S¥u¬OªÅªº
'¡ô¨ìi = 59:Crr=xD(A2009001/c)¬O°}¦C±ø¥ó¤£¦¨¥ß,´N¸õ¨ì End If
Crr = Brr
'¡ô·íi = 2:¥OCrrÅܦ¨¤@Ó¤WzBrr(1 To 999, 1 To 9)ªÅ°}¦C
'¡ôª½¨ìi = 50:¦A¥OCrrÅܦ¨¤@Ó¤WzBrr(1 To 999, 1 To 9)ªÅ°}¦C
' ,©Ò¥HBrr±qÀY¨ì§À³£¬O¤@ӪŪº®e¾¹
N = N + 1
'¡ô·íi = 2:¤@¶}©l N=1
'¡ôª½¨ìi = 50:N=2
xD(N) = T1
'¡ô·íi = 2:§â²Ä¤@ºØ ±M¯S®×¸¹ ˤJ¦r¨å¸Ì,KEY = 1,ITEM = ²Ä¤@ºØ ±M¯S®×¸¹
'¡ô·í²Ä¤@ºØ ±M¯S®×¸¹´N¦³¨âµ§¸ê®Æ¦b¦r¨å¸Ì,¥ý¬O¤@µ§¬O1ªºKEY,¥t¤@µ§¬O1ªºITEM
'¡ô·íMsgBox T1 & " : " & xD(T1) & " , " & N & " : " & xD(N)
'¡ôª½¨ìi = 50:§â²Ä¤GºØ ±M¯S®×¸¹ ˤJ¦r¨å¸Ì,KEY = 2,ITEM = ²Ä¤GºØ ±M¯S®×¸¹
End If
For j = 1 To 9 'i = 2 ³]°j°é±N¸ê®Æ±a¤JCrr°}¦C²Ä¤@¦C
Crr(xD(T1), j) = Arr(i, Array(9, 10, 11, 12, 22, 23, 24, 8, 5)(j - 1))
'¡ô·íi = 2:¤@¶}©l Crr(xD(T1), j) = Crr(1, j) ¦]¬° xD(T1)=1
' ,Array()«ü©w©ñ¤JªºÄæ¦ì,(j - 1)¬O¦]¬°Arrayªº²Ä¤@µ§¯Á¤Þ¬O0
'¡ô·íi >= 3:±M¯S®×¸¹³£¬OA2009001,©Ò¥H¦b«e¤èxD(T1)³£¦³¥[1 xD(T1) = xD(T1) + 1
'¡ôª½¨ìi = 50:±M¯S®×¸¹Åܦ¨A2104001,xD(T1)Åܦ¨1
'¡ô¨ìi = 59:±M¯S®×¸¹¤SÅܦ¨A2009001,©Ò¥HxD("A2009001") ITEM¦b«e¤è¤wÄ~Äò¥[1
Next j
xD(T1 & "/¹wºâÃB") = Arr(i, 21) '¹wºâª÷ÃB
'¡ô·íi = 2 ±N ²Ä¤@µ§ ±M¯S®×¸¹+"/¹wºâÃB" ˤJ¦r¨å,ITEM=²Ä¤@µ§ (±M¯S®×¸¹ªº ¹wºâª÷ÃB)
'¡ô,+"/¹wºâÃB" ¬O¬°¤F°Ï¹j«e±ªº ²Ä¤@µ§±M¯S®×¸¹ (ì¨Ó¦r¨å¸Ì¤w¸g¦³¤F)
'¡ô·íi >= 3 AND i < 50 :xD("A2009001/¹wºâÃB")¤@ª½«ü¦VArr(i, 21)
' ,¦pªG¹wºâ¦³¼W´î,³£¥u§ì³Ì«á¤@µ§ ±M¯S®×¸¹ªº¹wºâª÷ÃB
'¡ô·íi >= 50 ¨Ì¦¹ÅÞ¿èÄ~Äò§P©w
xD(T1 & "/¤w¥IÃB") = xD(T1 & "/¤w¥IÃB") + Arr(i, 23) '¤wµ¹¥Iª÷ÃB¤pp
'¡ô·íi = 2 ±N ²Ä¤@µ§ ±M¯S®×¸¹+"/¤w¥IÃB" ˤJ¦r¨å,ITEM=²Ä¤@µ§ (±M¯S®×¸¹ªº ¤w¥IÃB)
' ,¥[ "/¤w¥IÃB" ¬O¬°¤F°Ï¹j«e±ªº ²Ä¤@µ§±M¯S®×¸¹ (ì¨Ó¦r¨å¸Ì¤w¸g¦³¤F)
'¡ô·íi >= 3 AND i < 50 :xD("A2009001/¤w¥IÃB")¤@ª½«ü¦VArr(i, 23)²Ö¥[
'¡ô·íi >= 50 ¨Ì¦¹ÅÞ¿èÄ~Äò§P©w
If xD(T1 & "/" & T2) = 0 Then '±M¯S®×¸¹/½ÐÁʮ׸¹---±Æ°£«ÂÐ
'¦P¤@Ó ±M¯S®×¸¹/½ÐÁʮ׸¹ ªº ½ÐÁʪ÷ÃB »P ¥¼¥IÃB ¬O¬Û¦Pªº,©Ò¥H¶·±Æ°£«½Æ
'¡ô·íi = 2 :±M¯S®×¸¹/½ÐÁʮ׸¹ ¦b¦r¨å¬O§ä¤£¨ìªº
'¡ô·íi= 3 :±M¯S®×¸¹/½ÐÁʮ׸¹ »Pi=2®É¬Û¦P ITEM=1, IFªº±ø¥ó¤£¦¨¥ß
' ,±Æ°£«ÂÐ,´N¸õ¨ì End If
'¡ô·íi > 3 ¨Ì¦¹ÅÞ¿èÄ~Äò§P©w
xD(T1 & "/½ÐÁÊÃB") = xD(T1 & "/½ÐÁÊÃB") + Arr(i, 22) '½ÐÁʪ÷ÃB¤pp
'¡ô·íi = 2 ±N ²Ä¤@µ§ ±M¯S®×¸¹+"/½ÐÁÊÃB" ˤJ¦r¨å
' ,ITEM= 0 + ²Ä¤@µ§ (±M¯S®×¸¹ªº ½ÐÁÊÃB) 0¬O¦]¬°ì¦r¨å¸ÌªºITEM¬O0
' ,¥[ "/½ÐÁÊÃB" ¬O¬°¤F°Ï¹j«e±ªº ²Ä¤@µ§±M¯S®×¸¹ (ì¨Ó¦r¨å¸Ì¤w¸g¦³¤F)
'¡ô·íi > 3 ¨Ì¦¹ÅÞ¿èÄ~Äò§P©w,xD(T1 & "/½ÐÁÊÃB")«ü¦VArr(i, 22)²Ö¥[
xD(T1 & "/¥¼¥IÃB") = xD(T1 & "/¥¼¥IÃB") + Arr(i, 24) '¥¼µ¹¥Iª÷ÃB¤pp
'¡ô·íi = 2 ±N ²Ä¤@µ§ ±M¯S®×¸¹+"/¥¼¥IÃB" ˤJ¦r¨å
' ,ITEM= 0 + ²Ä¤@µ§ (±M¯S®×¸¹ªº ¥¼¥IÃB) 0¬O¦]¬°ì¦r¨å¸ÌªºITEM¬O0
' ,¥[ "/¥¼¥IÃB" ¬O¬°¤F°Ï¹j«e±ªº ²Ä¤@µ§±M¯S®×¸¹ (ì¨Ó¦r¨å¸Ì¤w¸g¦³¤F)
'¡ô·íi > 3 ¨Ì¦¹ÅÞ¿èÄ~Äò§P©w,xD(T1 & "/¥¼¥IÃB")«ü¦VArr(i, 24)²Ö¥[
xD(T1 & "/" & T2) = 1
'¡ô·íi = 2 ±N ±M¯S®×¸¹/½ÐÁʮ׸¹ ˤJ¦r¨å,ITEM=1
'¡ô·íi > 3:Ä~ÄòˤJ,Åý«e±±Æ°£«½Æ
End If
xD(T1 & "/c") = Crr
'¡ô·íi = 2 §â²Ä¤@µ§ªº ±M¯S®×¸¹+"/c" ˤJ¦r¨å,ITEM= Crr°}¦C
' ©Ò¥HxD¦r¨å¸Ì¸Ë¤F¤å¦r.¼Æ¦rÁÙ¦³°}¦C
'¡ô·íi >= 3:Crr°}¦C¤S¦h¤F¤@¦C¸ê®Æ,¥B¤SÅýµ¹xD(T1 & "/c")¨Ó¸Ë,ITEM= Crr°}¦C
i01: Next i
'°j°éÁ`µ²
'1.N=2,¦]¬°¥u¦³¨âºØ±M¯S®×¸¹,¦Ó¥B¦r¨å¸Ì¤]¥[§Ç¸¹ »P ±M¯S®×¸¹
' KEY=1:ITEM=A2009001,KEY=2:ITEM=A2104001
'2.xD("A2009001")¤w²Ö¿n¨ì59,xD("A2104001")¤w²Ö¿n¨ì17
'--------------------------------
Application.ScreenUpdating = False
Set xA = [ªí³æ!A1]
'¡ô¥O xA¬O "ªí³æ" ¤u§@ªí.[A1]Àx¦s®æ,©Ò¥HxA¤w¸g«ü¦VSheets("ªí³æ")
[ªí³æ!C1:H1].Merge: [ªí³æ!C2:H2].Merge: [ªí³æ!C3:H3].Merge
For i = 1 To N
If i > 1 Then [ªí³æ!A1:I4].Copy xA
T1 = xD(i)
'¡ô·íN = 1,T1=A2009001
'¡ô·íN = 2,T1=A2104001
R = xD(T1)
'¡ô·íN = 1,R=59
'¡ô·íN = 2,R=17
Crr = xD(T1 & "/c")
'¡ô±q¦r¨å¸Ì§â¨âÓ°}¦C±a¥X¨Ó
xA(3, 2) = T1
'¡ô¦]xA¤w¸g«ü¦VSheets("ªí³æ"),©Ò¥HxA(3, 2)=Sheets("ªí³æ").[B3]
xA(1, 9) = "¶µ¦¸:" & i & "/" & N
With xA(5).Resize(R, 9)
[ªí³æ!A4:I4].Copy .Cells
.Value = Crr
End With
xA(R + 5, 4) = "¤pp"
xA(R + 5, 5) = xD(T1 & "/½ÐÁÊÃB") '½ÐÁʪ÷ÃB¤pp
xA(R + 5, 6) = xD(T1 & "/¤w¥IÃB") '¤wµ¹¥Iª÷ÃB¤pp
xA(R + 5, 7) = xD(T1 & "/¥¼¥IÃB") '¥¼µ¹¥Iª÷ÃB¤pp
'-------------------------------------------------------
xA(3, 3) = "ºI¤î¤é´Á:" & Format([Á`ªí!C1], "yyyy/m/d")
xA(1, 2) = xD(T1 & "/¹wºâÃB") '¹wºâÁ`ÃB
xA(2, 2) = xD(T1 & "/¹wºâÃB") - xD(T1 & "/½ÐÁÊÃB") '³Ñ¾lÃB«×
Set xA = xA(R + 6)
xA.PageBreak = xlPageBreakManual '³]©w¤À¶½u
Next i
Set xD = Nothing: Erase Arr, Brr, Crr
Sheets("ªí³æ").Activate
[C3].Select
[H:H].NumberFormatLocal = "yyyy/mm/dd"
[E:G].NumberFormatLocal = "* #,##0"
[A:C].NumberFormatLocal = "_($* #,##0_);[¬õ¦â]_($* (#,##0);_(@_)"
MsgBox Timer - tm
Application.ScreenUpdating = Ture
End Sub |
|