Board logo

¼ÐÃD: Ū¨ú¤ÎÂkÃþ¤Î®Ø綫®æ¦¡ [¥´¦L¥»­¶]

§@ªÌ: 198188    ®É¶¡: 2024-2-6 11:19     ¼ÐÃD: Ū¨ú¤ÎÂkÃþ¤Î®Ø綫®æ¦¡

ªþ¥ó¬O¤@­Ó¦h¤u§@­¶ªº¤¬¬Û©â¨ú¸ê®Æªº¼Ò¦¡¡AŪ¨ú¦Z²o¯A¤@¨Ç®Ø綫¡AªÅ®æ®æ¦¡µ¥°ÝÃD¡A½Ð¦U¤j¤jÀ°¦£¬Ý¬Ý¦³¨S¦³¤èªk¸Ñ¨M¡AÁÂÁ¡C
§@ªÌ: 198188    ®É¶¡: 2024-2-7 10:20

ªþ¥ó¬O¤@­Ó¦h¤u§@­¶ªº¤¬¬Û©â¨ú¸ê®Æªº¼Ò¦¡¡AŪ¨ú¦Z²o¯A¤@¨Ç®Ø綫¡AªÅ®æ®æ¦¡µ¥°ÝÃD¡A½Ð¦U¤j¤jÀ°¦£¬Ý¬Ý¦³ ...
198188 µoªí©ó 2024-2-6 11:19



   ªþ¤W©î¤À²M³æ®æ¦¡ºc«ä¡A§Æ±æ¯à°÷µ¹¦U¦ì¤j¤j§ó¥[®e©ö²z¸Ñ¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-7 13:27

¦^´_ 1# 198188


    ÁÂÁ«e½úµoªí¦¹¥DÃD»P½d¨Ò
«á¾ÇÂǦ¹©«½m²ß°}¦C»P¦r¨å,³o½d¨Ò¦nÃø,¦U¬q¸¨©ú²Óªº¦C¶¶§Ç§ä¤£¨ì³W«h,¾Ç²ß¤è®×¦p¤U,½Ð«e½ú°Ñ¦Ò

Option Explicit
Sub TEST()
Dim Brr(1 To 100, 1 To 14), A, Z, Q, P, i&, j%, R&, C%, N&, x%, T$, T14$, T15$, T5$, V8&, V9&, V10#, Tp1$, Tp3$, Tp5$, Y&
Dim PGNr, Rackr, Itemr, PGr, DPLs As Worksheet, xR As Range, xRs As Range, xRe As Range
Set Z = CreateObject("Scripting.Dictionary"): Application.ScreenUpdating = False
PGNr = [PGN!A1].CurrentRegion: Rackr = [Rack!A1].CurrentRegion: Itemr = [Item!A1].CurrentRegion: PGr = [PG!A1].CurrentRegion
Set DPLs = Sheets("DPL"): DPLs.Activate: T = [J3]: DPLs.UsedRange.Offset(19).EntireRow.Delete: Set xR = [A20]: xR.Resize(1000, 14).Borders.LineStyle = 1
For i = 2 To UBound(PGr)
   If Z(PGr(i, 1) & "^") = "" Then Z(PGr(i, 1) & "^") = PGr(i, 2) Else MsgBox "PGªí " & PGr(i, 1) & " ­«½Æ": Exit Sub
Next
For i = 2 To UBound(Rackr)
   If Rackr(i, 11) <> T Then GoTo i01
   T14 = Rackr(i, 14): T5 = Rackr(i, 5): T15 = Rackr(i, 15)
   If Not Z.Exists(T15) Then R = N Mod 3 + 1: C = N \ 3: N = N + 1: Brr(R, Array(1, 3, 4)(C)) = T15: Z(T15) = ""
   If InStr("," & Z(T14 & "/GD") & ",", "," & T15 & ",") = 0 Then Z(T14 & "/GD") = Z(T14 & "/GD") & "," & T15
   If InStr("," & Z(T14 & "/RN") & ",", "," & T5 & ",") = 0 Then Z(T14 & "/RN") = Z(T14 & "/RN") & "," & T5: Z(T5 & "|") = i Else MsgBox "Rackªí " & T5 & " ­«½Æ": Exit Sub
i01: Next
DPLs.[G12].Resize(3, 4) = Brr: DPLs.[G15] = "TOTAL " & N & " X 45'HC CONTAINER": N = 0
For i = 2 To UBound(PGNr)
   If PGNr(i, 1) <> T Then GoTo i02
   If Z.Exists(PGNr(i, 2) & "/GD") Then Z(PGNr(i, 2) & "/GD") = "CONTAINER NO.:" & Mid(Z(PGNr(i, 2) & "/GD"), 2) & vbCrLf & PGNr(i, 3) ': MsgBox Z(PGNr(i, 2) & "/GD")
i02: Next
For i = 2 To UBound(Itemr)
   If Z.Exists(Itemr(i, 3) & "|") Then Z(Itemr(i, 3) & "|") = Z(Itemr(i, 3) & "|") & "," & i
Next
For Each A In Z.KEYS
   If Right(A, 3) <> "/RN" Then GoTo A01 Else Q = Split(Z(A), ","): xR = Z(Split(A, "/RN")(0) & "/GD")
   With xR.Resize(, 14): .Merge: .Font.Size = 9: .Font.Bold = True: .Rows.RowHeight = 52: End With
   For i = 1 To UBound(Q)
      Set xR = xR(2): xR.Resize(1, 14).Interior.ColorIndex = 15: xR.Resize(1, 14).Font.Bold = True
      With xR.Resize(1, 4): .Merge: .Font.Size = 12:  .Value = "'" & Q(i): End With
      xR(1, 6).Resize(, 2).Merge: xR(1, 10).Resize(, 5).Merge
      P = Split(Z(Q(i) & "|"), ","): R = Val(P(0))
      xR(1, 8) = Val(Rackr(R, 6)): xR(1, 9) = Val(Rackr(R, 7)): xR(1, 10) = Rackr(R, 8) & " x " & Rackr(R, 9) & " x " & Rackr(R, 10)
      V8 = V8 + xR(1, 8): V9 = V9 + xR(1, 9): V10 = V10 + (Val(Rackr(R, 8)) * Val(Rackr(R, 9)) * Val(Rackr(R, 10)) / 10 ^ 9): Set xRs = xR(2, 8): Set xRe = xR(2, 1)
      For j = 1 To UBound(P)
         Tp1 = Itemr(P(j), 5): Tp3 = Z(Itemr(P(j), 6) & "^"): Tp5 = Itemr(P(j), 4)
         Y = Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5)
         If Y = 0 Then
            Set xR = xR(2): xR.Resize(1, 14).Font.Size = 9: xR = Tp1: xR(1, 3) = Tp3: xR(1, 5) = Tp5: xR(1, 6) = Val(Itemr(P(j), 7))
            Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5) = xR.Row: GoTo j01
         End If
         Cells(Y, 6) = Cells(Y, 6) + Val(Itemr(P(j), 7))
j01:  Next
      With Range(xRe, xR(1, 14))
         .Sort KEY1:=.Item(6), Order1:=1, Header:=2: .Sort KEY1:=.Item(5), Order1:=1, Key2:=.Item(3), Order2:=1, Key3:=.Item(1), Order2:=1, Header:=2
         For R = 1 To .Rows.Count: .Cells(R, 1).Resize(1, 2).Merge: .Cells(R, 3).Resize(1, 2).Merge: .Cells(R, 6).Resize(1, 2).Merge: Next
      End With
      Range(xRs, xR(1, 14)).Merge
   Next
   Set xR = xR(2)
A01: Next
Set xR = xR(2): xR(1, 5) = "TOTAL": xR(1, 8) = V8: xR(1, 9) = V9: xR(1, 10) = V10: xR(1, 10).Resize(1, 5).Merge
With xR.Resize(1, 14): .Font.Size = 12: .Font.Bold = True: End With
Set Z = Nothing: Erase PGNr, Rackr, Itemr, PGr
End Sub

¯¬¦U¦ì«e½ú ·s¬K´r§Ö
§@ªÌ: mark15jill    ®É¶¡: 2024-2-7 15:57

ªþ¤W©î¤À²M³æ®æ¦¡ºc«ä¡A§Æ±æ¯à°÷µ¹¦U¦ì¤j¤j§ó¥[®e©ö²z¸Ñ¡C
198188 µoªí©ó 2024-2-7 10:20



    ¦P½g°ÝÃD «Øij ¥Î­×§ï ©Î¬O ¦^ÂÐ.. ¤£µM«Ü¶Ã
§@ªÌ: 198188    ®É¶¡: 2024-2-7 16:43

¦^´_ 3# Andy2483


ÁÂÁ±zªº¸Ñµª¡A¸Õ¹Lµ²ªG¦Z¡A¦³ªþ¥óª`ÄÀ¡A¤è«K²M´·³W«h¡C
¥t¥~¥i§_¦bVBA¥[¤Wª`ÄÀ¡A¤è«K¾Ç²ß¡AÁÂÁ¡C
§@ªÌ: 198188    ®É¶¡: 2024-2-8 08:50

¦^´_ 4# mark15jill


    ÁÂÁ¤j¤j´£¿ô¡C:lol
§@ªÌ: Andy2483    ®É¶¡: 2024-2-19 11:58

¦^´_ 5# 198188

¥ý¬Ý¬Ý°õ¦æ«á¬O§_¬°»Ý¨Dªº¦C¦L¤À­¶,¦A¬Ý¬Ý«áÄò¦p¦ó¸Ñ
[attach]37447[/attach]
§@ªÌ: 198188    ®É¶¡: 2024-2-19 15:01

¦^´_ 7# Andy2483


    ªþ¤W¡§VBA¥´¦L®æ¦¡¡¨¡A³o¬O®Ú¾Ú±zªºVBA °µ¥X¨Óªº®ÄªG¡A¥t¤@­Óªþ¥ó¡§¥¿½T®æ¦¡¡¨¬O§Ú·Q­nªº®ÄªG¡C
®Ú¾Ú®ÄªG¡A¦n¹³Âù¼Æªº¥u¯àÅã¥Ü¤@¦æ¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-19 15:15

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-2-19 15:27 ½s¿è

¦^´_ 8# 198188


    ³o¼Ë¦^´_µLªk½T»{¤À­¶¬O§_¥¿½T,¦pªG¦A½Õ¾ã¹LÄæ¼e©Î¤ñ¨Ò´N±o­«ºâ°Ñ¼Æ
¥H¤Uªþ¥ó¬O7#Àɮ׶ץXPDFÀɪºµ²ªG,»P8#¦^´_Âû¦PÀnÁ¿
[attach]37453[/attach]

¥H¤U¬O«á¾Ç¤À­¶¹wÄýªºª¬ªp:
[attach]37454[/attach]
§@ªÌ: 198188    ®É¶¡: 2024-2-19 15:58

¦^´_ 9# Andy2483

§Ú¥´¦LPDF Á`¬O§â³Ì«á¤@¦æ±À¨ì²Ä¤G­¶¡A³o­Ó¥i¯à¬O¤j®a¥´¦LªºÃä¬É¤£¤@¼Ë§a¡C


¥t¥~¦b¬Û¦PªºSRùØ­± ©M ¦b¥´¦L®É¦P¤@­¶¡A
Äæ C ¤ÎÄæE ¦pªG¬Û¦P¡A¥u­n²Ä¤@¦æ¦³¤å¦r¡A
Äæ C ²Ä¤@¦æ¦³®Ø綫¡A¤§«áªº©Ò¦³¬Û¦Pªº¡A¥u­n¥|Ã䦳®Ø綫
Äæ E ©Ò¦³¬Û¦Pªº¡A¥u­n¥|Ã䦳®Ø綫
ÄæH,I,J,K,L,M,N ¥|Ã䦳®Ø綫
¡]¤§«e¦n¹³¥i¥H¡A²{¦bÅܦ¨¨S¦³³o­Ó¥\¯à¤F¡^
§@ªÌ: Andy2483    ®É¶¡: 2024-2-19 16:15

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-2-19 16:16 ½s¿è

¦^´_ 10# 198188


7#ªº½d¨Ò¥u¬O·Q¥ý½T»{¤À­¶¬O§_¥¿½T,¦pªG¤À­¶²Å¦X»Ý¨D¦A³B²z®Ø½u¤Î¸É²Ä¤@¦CªÅ¥Õ®æ°ÝÃD
¦C¦L¸òEXCELª©¥»¤Î¨ä¥¦°Ñ¼Æ¦³Ãö
§@ªÌ: 198188    ®É¶¡: 2024-2-19 16:39

¦^´_ 9# Andy2483


   ³o­Ó¤À­¶¥¿½T
§@ªÌ: Andy2483    ®É¶¡: 2024-2-19 16:45

¦^´_ 10# 198188

¬Ý¬ÝÁÙ·|¤£·| "«á¤@¦æ±À¨ì²Ä¤G­¶"...µ¥°ÝÃD,¦pªG¤À­¶¥¿½T¦AÄ~Äò
[attach]37455[/attach]
§@ªÌ: 198188    ®É¶¡: 2024-2-19 16:51

[attach]37456[/attach][attach]37456[/attach]¦^´_ 13# Andy2483


    ÁÙ¬O¤@¼Ë¡C§ÚºI¹Ï¤F¤@¤UÃä¬É³]©w¹Ï¤ùÅý§A¬Ý¬Ý¤j®aªº³]¸m¤£¤@¼Ë¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-19 17:46

¦^´_ 14# 198188


    ¬Ý³oºI¹Ïµe­±¦n¹³¬O±z´ú¸ÕªºÀɤ£¤@¼Ë¡A¨Ã¤£¬O¥Î«á¾Ç¤W¶ÇªºÀÉ®×
»P¨ä¶Ã²q¤£¦p½Ð¤W¶Ç¹ê»Ú­n´ú¸ÕªºÀÉ®×
§@ªÌ: 198188    ®É¶¡: 2024-2-19 18:07

¦^´_ 15# Andy2483


    ¬O¦P¤@­ÓExcel¡A ¤£¹L¸ÑÀ£¦Z¡AµLªk¹B¦æVBA, »Ý­n§ó¦W¦Z¤~¯à¹B¦æ¡C
[attach]37458[/attach]
§@ªÌ: Andy2483    ®É¶¡: 2024-2-19 18:53

¦^´_ 16# 198188


    ²{¦b¨S¦³PC¥i¥H´ú¸Õ¡A«e½ú¥i¥H½Õ¾ãµ{¦¡³Ì«á¦³­Ó1.35ªº°Ñ¼Æ §â¥¦¸Õ§ï¬°1.3 ©Î 1.25¦A°õ¦æ¬Ý¬Ý
§@ªÌ: 198188    ®É¶¡: 2024-2-20 08:17

¦^´_ 17# Andy2483

§ï爲1.3¦Z¡A´ú¸Õ¨S¦³°ÝÃD¤F
§@ªÌ: Andy2483    ®É¶¡: 2024-2-20 14:21

¦^´_ 18# 198188

ÁÂÁ½׾Â,ÁÂÁ«e½ú¦^´_
«á¾ÇÂǦ¹©«¾Ç²ß¨ì«Ü¦hª¾ÃÑ,¾Ç²ßªº¤è®×¦p¤U,½Ð«e½ú°Ñ¦Ò
[attach]37459[/attach]
§@ªÌ: 198188    ®É¶¡: 2024-2-20 17:19

¦^´_ 19# Andy2483


    ¥X²{¤§«eªº°ÝÃD¡A³Ì«á¤@¦æÅܦ¨²Ä¤G­¶¡A内®e¦³¶Ã½X¡A¤£ª¾¹D«ç¼Ë§ï¡C
Option Explicit
Sub TEST()
Dim Brr(1 To 100, 1 To 14), A, Z, Q, P, i&, j%, R&, C%, N&, x%, T$, T14$, T15$, T5$, V8&, V9&, V10#, Tp1$, Tp3$, Tp5$, Y&, SS$, 夹肈õä¤àÇx££#
Dim PGNr, Rackr, Itemr, PGr, DPLs As Worksheet, xR As Range, xRs As Range, TT$, TH#, ii, RH, Sh#, xRc As Range, xRe As Range
Set Z = CreateObject("Scripting.Dictionary"): Application.ScreenUpdating = False: Application.DisplayAlerts = False: Sh = Rows(17).RowHeight / 32
夹肈õä¤àÇx££ = [O1]: PGNr = [PGN!A1].CurrentRegion: Rackr = [Rack!A1].CurrentRegion: Itemr = [Item!A1].CurrentRegion: PGr = [PG!A1].CurrentRegion
Set DPLs = Sheets("DPL"): DPLs.Activate: T = [J3]: DPLs.UsedRange.Offset(19).EntireRow.Delete: Set xR = [A20]
Cells.VerticalAlignment = xlCenter: ActiveSheet.ResetAllPageBreaks: [A1].Activate: For i = 1 To 19: TH = TH + Rows(i).RowHeight: Next
For i = 2 To UBound(PGr)
   If Z(PGr(i, 1) & "^") = "" Then Z(PGr(i, 1) & "^") = PGr(i, 2) Else MsgBox "PG " & PGr(i, 1) & " ¬¾": Exit Sub
Next
For i = 2 To UBound(Rackr)
   If Rackr(i, 11) <> T Then GoTo i01
   T14 = Rackr(i, 14): T5 = Rackr(i, 5): T15 = Rackr(i, 15)
   If Not Z.Exists(T15) Then R = N Mod 3 + 1: C = N \ 3: N = N + 1: Brr(R, Array(1, 3, 4)(C)) = T15: Z(T15) = ""
   If InStr("," & Z(T14 & "/GD") & ",", "," & T15 & ",") = 0 Then Z(T14 & "/GD") = Z(T14 & "/GD") & "," & T15
   If InStr("," & Z(T14 & "/RN") & ",", "," & T5 & ",") = 0 Then Z(T14 & "/RN") = Z(T14 & "/RN") & "," & T5: Z(T5 & "|") = i Else MsgBox "Rack " & T5 & " ¬¾": Exit Sub
i01: Next
DPLs.[G12].Resize(3, 4) = Brr: DPLs.[G15] = "TOTAL " & N & " X 45'HC CONTAINER": N = 0
For i = 2 To UBound(PGNr)
   If PGNr(i, 1) <> T Then GoTo i02
   If Z.Exists(PGNr(i, 2) & "/GD") Then Z(PGNr(i, 2) & "/GD") = "CONTAINER NO.:" & Mid(Z(PGNr(i, 2) & "/GD"), 2) & vbCrLf & PGNr(i, 3)
i02: Next
For i = 2 To UBound(Itemr)
   If Z.Exists(Itemr(i, 3) & "|") Then Z(Itemr(i, 3) & "|") = Z(Itemr(i, 3) & "|") & "," & i
Next
For Each A In Z.KEYS
   If Right(A, 3) <> "/RN" Then GoTo A01 Else Q = Split(Z(A), ","): xR = Z(Split(A, "/RN")(0) & "/GD")
   With xR.Resize(, 14): .Merge: .Font.Size = 9: .Font.Bold = True: .Rows.RowHeight = 52 * Sh: End With
   For i = 1 To UBound(Q)
      Set xR = xR(2): xR.Resize(1, 14).Interior.ColorIndex = 15: xR.Resize(1, 14).Font.Bold = True: xR.Rows.RowHeight = 27 * Sh
      With xR.Resize(1, 4): .Merge: .Font.Size = 12:  .Value = "'" & Q(i): End With
      xR(1, 6).Resize(, 2).Merge: xR(1, 10).Resize(, 5).Merge
      P = Split(Z(Q(i) & "|"), ","): R = Val(P(0))
      xR(1, 8) = Val(Rackr(R, 6)): xR(1, 9) = Val(Rackr(R, 7)): xR(1, 10) = Rackr(R, 8) & " x " & Rackr(R, 9) & " x " & Rackr(R, 10)
      V8 = V8 + xR(1, 8): V9 = V9 + xR(1, 9): V10 = V10 + (Val(Rackr(R, 8)) * Val(Rackr(R, 9)) * Val(Rackr(R, 10)) / 10 ^ 9): Set xRs = xR(2, 8): Set xRs = xR(2, 1)
      For j = 1 To UBound(P)
         Tp1 = Itemr(P(j), 5): Tp3 = Z(Itemr(P(j), 6) & "^"): Tp5 = Itemr(P(j), 4)
         Y = Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5)
         If Y = 0 Then
            Set xR = xR(2): xR.Resize(1, 14).Font.Size = 9: xR = Tp1: xR(1, 3) = Tp3: xR(1, 5) = Tp5: xR(1, 6) = Val(Itemr(P(j), 7))
            Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5) = xR.Row: xR.Rows.RowHeight = 27 * Sh: GoTo j01
         End If
         Cells(Y, 6) = Cells(Y, 6) + Val(Itemr(P(j), 7))
j01:  Next
      With Range(xRs, xR(1, 14))
         .Sort KEY1:=.Item(6), Order1:=1, Header:=2: .Sort KEY1:=.Item(5), Order1:=1, Key2:=.Item(3), Order2:=1, Key3:=.Item(1), Order2:=1, Header:=2
         For R = 1 To .Rows.Count: .Cells(R, 1).Resize(1, 2).Merge: .Cells(R, 3).Resize(1, 2).Merge: .Cells(R, 6).Resize(1, 2).Merge: .Cells(R, 8).Resize(1, 7).Merge: Next
      End With
   Next
   Set xR = xR(2)
A01: Next
Cells.VerticalAlignment = xlCenter: If ActiveSheet.VPageBreaks.Count + 1 = 2 Then ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
xR(1, 5) = "TOTAL": xR.Resize(, 4).Merge: xR(1, 5).Resize(, 3).Merge: xR(1, 8) = V8: xR(1, 9) = V9: xR(1, 10) = Round(V10, 2): xR(1, 10).Resize(1, 5).Merge: xR.Rows.RowHeight = 27 * Sh
With xR.Resize(1, 14): .Font.Size = 12: .Font.Bold = True: End With
ActiveSheet.Names.Add Name:="PrintArea", RefersTo:=Range([A1], xR(, 14)): ActiveSheet.PageSetup.PrintArea = "PrintArea"
For i = 20 To xR.Row '800-327.3=472.7 : 472.7/327.3=1.44
   TT = Cells(i, 3) & "/" & Cells(i, 5)
   If TT = "/" Then GoTo i03
   If TT = SS Or SS = "" Then
      If xRc Is Nothing Then Set xRc = Cells(i, 3): Set xRe = Cells(i, 5) Else Set xRc = Union(xRc, Cells(i, 3)): Set xRe = Union(xRe, Cells(i, 5))
   End If
i03: RH = RH + Cells(i, 1).RowHeight
   If Cells(i + 1, 3) & "/" & Cells(i + 1, 5) <> TT Or RH / TH > 夹肈õä¤àÇx££ Then
      If Not xRc Is Nothing Then
         If xRc.Count > 1 Then With Intersect(xRc, xRc.Offset(1)): .Merge: .Value = "": End With: xRe.Merge: xRe.VerticalAlignment = xlTop: xRc.Offset(, 5).Merge
      End If
      Set xRc = Nothing: Set xRe = Nothing: SS = Cells(i + 1, 3) & "/" & Cells(i + 1, 5)
   End If
   If RH / TH > 夹肈õä¤àÇx££ Then Cells(i + 1, 1).PageBreak = xlPageBreakManual: RH = 0
Next
Intersect(Range("PrintArea"), Range("PrintArea").Offset(19)).Borders.LineStyle = 1
Set Z = Nothing: Erase PGNr, Rackr, Itemr, PGr: Set xR = Nothing: Set xRs = Nothing: Set xRc = Nothing: Set xRe = Nothing
End Sub
§@ªÌ: Andy2483    ®É¶¡: 2024-2-20 17:44

¦^´_ 20# 198188


Àx¦s®æO1ªº1.35 §ï¬°1.3 ¸Õ¸Õ¬Ý
§Ú§Ñ°O¤F²Å骩·|¶Ã½X¡A¤£¼vÅT°õ¦æ´N¨SÃö¨t
§@ªÌ: 198188    ®É¶¡: 2024-2-20 18:29

¦^´_ 21# Andy2483


    ¦b­þ­Ó¦ì¸m¡A¦]爲¶Ã½X¡A§Ú¤À¿ì¤£¥X¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-20 18:47

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-2-21 07:07 ½s¿è

¦^´_ 22# 198188


    Àx¦s®æO1
¦bªí®æªºO1¤W¬O1.35§ï¬° 1.3 ¸Õ¸Õ¬Ý
[attach]37460[/attach]

Option Explicit
Sub TEST()
Dim Brr(1 To 100, 1 To 14), A, Z, Q, P, i&, j%, R&, C%, N&, x%, T$, T14$, T15$, T5$, V8&, V9&, V10#, Tp1$, Tp3$, Tp5$, Y&, SS$, Tts#
Dim PGNr, Rackr, Itemr, PGr, DPLs As Worksheet, xR As Range, xRs As Range, TT$, TH#, ii, RH, Sh#, xRc As Range, xRe As Range
Set Z = CreateObject("Scripting.Dictionary"): Application.ScreenUpdating = False: Application.DisplayAlerts = False: Sh = Rows(17).RowHeight / 32
Tts = [O1]: PGNr = [PGN!A1].CurrentRegion: Rackr = [Rack!A1].CurrentRegion: Itemr = [Item!A1].CurrentRegion: PGr = [PG!A1].CurrentRegion
Set DPLs = Sheets("DPL"): DPLs.Activate: T = [J3]: DPLs.UsedRange.Offset(19).EntireRow.Delete: Set xR = [A20]
Cells.VerticalAlignment = xlCenter: ActiveSheet.ResetAllPageBreaks: [A1].Activate: For i = 1 To 19: TH = TH + Rows(i).RowHeight: Next
For i = 2 To UBound(PGr)
   If Z(PGr(i, 1) & "^") = "" Then Z(PGr(i, 1) & "^") = PGr(i, 2) Else MsgBox "PGªí " & PGr(i, 1) & " ­«½Æ": Exit Sub
Next
For i = 2 To UBound(Rackr)
   If Rackr(i, 11) <> T Then GoTo i01
   T14 = Rackr(i, 14): T5 = Rackr(i, 5): T15 = Rackr(i, 15)
   If Not Z.Exists(T15) Then R = N Mod 3 + 1: C = N \ 3: N = N + 1: Brr(R, Array(1, 3, 4)(C)) = T15: Z(T15) = ""
   If InStr("," & Z(T14 & "/GD") & ",", "," & T15 & ",") = 0 Then Z(T14 & "/GD") = Z(T14 & "/GD") & "," & T15
   If InStr("," & Z(T14 & "/RN") & ",", "," & T5 & ",") = 0 Then Z(T14 & "/RN") = Z(T14 & "/RN") & "," & T5: Z(T5 & "|") = i Else MsgBox "Rackªí " & T5 & " ­«½Æ": Exit Sub
i01: Next
DPLs.[G12].Resize(3, 4) = Brr: DPLs.[G15] = "TOTAL " & N & " X 45'HC CONTAINER": N = 0
For i = 2 To UBound(PGNr)
   If PGNr(i, 1) <> T Then GoTo i02
   If Z.Exists(PGNr(i, 2) & "/GD") Then Z(PGNr(i, 2) & "/GD") = "CONTAINER NO.:" & Mid(Z(PGNr(i, 2) & "/GD"), 2) & vbCrLf & PGNr(i, 3)
i02: Next
For i = 2 To UBound(Itemr)
   If Z.Exists(Itemr(i, 3) & "|") Then Z(Itemr(i, 3) & "|") = Z(Itemr(i, 3) & "|") & "," & i
Next
For Each A In Z.KEYS
   If Right(A, 3) <> "/RN" Then GoTo A01 Else Q = Split(Z(A), ","): xR = Z(Split(A, "/RN")(0) & "/GD")
   With xR.Resize(, 14): .Merge: .Font.Size = 9: .Font.Bold = True: .Rows.RowHeight = 52 * Sh: End With
   For i = 1 To UBound(Q)
      Set xR = xR(2): xR.Resize(1, 14).Interior.ColorIndex = 15: xR.Resize(1, 14).Font.Bold = True: xR.Rows.RowHeight = 27 * Sh
      With xR.Resize(1, 4): .Merge: .Font.Size = 12:  .Value = "'" & Q(i): End With
      xR(1, 6).Resize(, 2).Merge: xR(1, 10).Resize(, 5).Merge
      P = Split(Z(Q(i) & "|"), ","): R = Val(P(0))
      xR(1, 8) = Val(Rackr(R, 6)): xR(1, 9) = Val(Rackr(R, 7)): xR(1, 10) = Rackr(R, 8) & " x " & Rackr(R, 9) & " x " & Rackr(R, 10)
      V8 = V8 + xR(1, 8): V9 = V9 + xR(1, 9): V10 = V10 + (Val(Rackr(R, 8)) * Val(Rackr(R, 9)) * Val(Rackr(R, 10)) / 10 ^ 9): Set xRs = xR(2, 8): Set xRs = xR(2, 1)
      For j = 1 To UBound(P)
         Tp1 = Itemr(P(j), 5): Tp3 = Z(Itemr(P(j), 6) & "^"): Tp5 = Itemr(P(j), 4)
         Y = Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5)
         If Y = 0 Then
            Set xR = xR(2): xR.Resize(1, 14).Font.Size = 9: xR = Tp1: xR(1, 3) = Tp3: xR(1, 5) = Tp5: xR(1, 6) = Val(Itemr(P(j), 7))
            Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5) = xR.Row: xR.Rows.RowHeight = 27 * Sh: GoTo j01
         End If
         Cells(Y, 6) = Cells(Y, 6) + Val(Itemr(P(j), 7))
j01:  Next
      With Range(xRs, xR(1, 14))
         .Sort KEY1:=.Item(6), Order1:=1, Header:=2: .Sort KEY1:=.Item(5), Order1:=1, Key2:=.Item(3), Order2:=1, Key3:=.Item(1), Order2:=1, Header:=2
         For R = 1 To .Rows.Count: .Cells(R, 1).Resize(1, 2).Merge: .Cells(R, 3).Resize(1, 2).Merge: .Cells(R, 6).Resize(1, 2).Merge: .Cells(R, 8).Resize(1, 7).Merge: Next
      End With
   Next
   Set xR = xR(2)
A01: Next
Cells.VerticalAlignment = xlCenter: If ActiveSheet.VPageBreaks.Count + 1 = 2 Then ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
xR(1, 5) = "TOTAL": xR.Resize(, 4).Merge: xR(1, 5).Resize(, 3).Merge: xR(1, 8) = V8: xR(1, 9) = V9: xR(1, 10) = Round(V10, 2): xR(1, 10).Resize(1, 5).Merge: xR.Rows.RowHeight = 27 * Sh
With xR.Resize(1, 14): .Font.Size = 12: .Font.Bold = True: End With
ActiveSheet.Names.Add Name:="PrintArea", RefersTo:=Range([A1], xR(, 14)): ActiveSheet.PageSetup.PrintArea = "PrintArea"
For i = 20 To xR.Row '800-327.3=472.7 : 472.7/327.3=1.44
   TT = Cells(i, 3) & "/" & Cells(i, 5)
   If TT = "/" Then GoTo i03
   If TT = SS Or SS = "" Then
      If xRc Is Nothing Then Set xRc = Cells(i, 3): Set xRe = Cells(i, 5) Else Set xRc = Union(xRc, Cells(i, 3)): Set xRe = Union(xRe, Cells(i, 5))
   End If
i03: RH = RH + Cells(i, 1).RowHeight
   If Cells(i + 1, 3) & "/" & Cells(i + 1, 5) <> TT Or RH / TH > Tts Then
      If Not xRc Is Nothing Then
         If xRc.Count > 1 Then With Intersect(xRc, xRc.Offset(1)): .Merge: .Value = "": End With: xRe.Merge: xRe.VerticalAlignment = xlTop: xRc.Offset(, 5).Merge
      End If
      Set xRc = Nothing: Set xRe = Nothing: SS = Cells(i + 1, 3) & "/" & Cells(i + 1, 5)
   End If
   If RH / TH > Tts Then Cells(i + 1, 1).PageBreak = xlPageBreakManual: RH = 0
Next
Intersect(Range("PrintArea"), Range("PrintArea").Offset(19)).Borders.LineStyle = 1
Set Z = Nothing: Erase PGNr, Rackr, Itemr, PGr: Set xR = Nothing: Set xRs = Nothing: Set xRc = Nothing: Set xRe = Nothing
End Sub
§@ªÌ: 198188    ®É¶¡: 2024-2-21 14:58

¦^´_ 23# Andy2483


    ¥i¥H¤F¡AÁÂÁ¡C

¥t¥~¦³­Ó°ÝÃD¡A§Ú¥Î¿ý»s¤è¦¡¼g¤F¤@­ÓVBA ¬O¦bªþ¥óùثإߨâ­Ó¼Ï¯Ã¤ÀªRªí¡C¤£¹L¹B¦æªº®É­Ô¦b¤U­±³o­Ó¦ì¸m¥d¦í¤F¡C   ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "sheet1!R1C1:R1048576C12", Version:=8).CreatePivotTable TableDestination:= _
        "sheet1!R1C26", TableName:="PivotTable21", DefaultVersion:=8
½ÐÀ°§Ú¬Ý¬Ý¬O­þùØ¥X²{°ÝÃD¡C
¥t¥~¯à¤£¯àÀ°¦£§ï¨}¤@¤U¡A
1) ÄæZ -AAªº¼Ï¯Ã¤ÀªRªí
¸ê®Æ¨Ó·½±qA1  - L1  :  A (ÄæB³Ì«á¤@¦æ¡^ -  L(ÄæB³Ì«á¤@¦æ¡^
Äæ¦ì²M³æ¡G
¦C ¡G SECTION & LENGTH
­È ¡G ¥[Á`QTY

2) ÄæAC-ADªº¼Ï¯Ã¤ÀªRªí
¸ê®Æ¨Ó·½±qN1  - V1  :  N (ÄæP³Ì«á¤@¦æ¡^ -  V(ÄæP³Ì«á¤@¦æ¡^
Äæ¦ì²M³æ¡G
¦C ¡G SECTION & LENGTH
­È ¡G ¥[Á`Q'TY

Sub Macro2()
  Application.CutCopyMode = False
    ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
        "sheet1!R1C1:R1048576C12", Version:=8).CreatePivotTable TableDestination:= _
        "sheet1!R1C26", TableName:="PivotTable21", DefaultVersion:=8
    Sheets("sheet1)").Select
    Cells(1, 26).Select
    With ActiveSheet.PivotTables("PivotTable21")
        .ColumnGrand = True
        .HasAutoFormat = True
        .DisplayErrorString = False
        .DisplayNullString = True
        .EnableDrilldown = True
        .ErrorString = ""
        .MergeLabels = False
        .NullString = ""
        .PageFieldOrder = 2
        .PageFieldWrapCount = 0
        .PreserveFormatting = True
        .RowGrand = True
        .SaveData = True
        .PrintTitles = False
        .RepeatItemsOnEachPrintedPage = True
        .TotalsAnnotation = False
        .CompactRowIndent = 1
        .InGridDropZones = False
        .DisplayFieldCaptions = True
        .DisplayMemberPropertyTooltips = False
        .DisplayContextTooltips = True
        .ShowDrillIndicators = True
        .PrintDrillIndicators = False
        .AllowMultipleFilters = False
        .SortUsingCustomLists = True
        .FieldListSortAscending = False
        .ShowValuesRow = False
        .CalculatedMembersInFilters = False
        .RowAxisLayout xlCompactRow
    End With
    With ActiveSheet.PivotTables("PivotTable21").PivotCache
        .RefreshOnFileOpen = False
        .MissingItemsLimit = xlMissingItemsDefault
    End With
    ActiveSheet.PivotTables("PivotTable21").RepeatAllLabels xlRepeatLabels
    ActiveWorkbook.ShowPivotTableFieldList = True
    With ActiveSheet.PivotTables("PivotTable21").PivotFields("SECTION")
        .Orientation = xlRowField
        .Position = 1
    End With
    With ActiveSheet.PivotTables("PivotTable21").PivotFields("LENGTH")
        .Orientation = xlRowField
        .Position = 2
    End With
    ActiveSheet.PivotTables("PivotTable21").AddDataField ActiveSheet.PivotTables( _
        "PivotTable21").PivotFields("QTY"), "Count of QTY", xlCount
    With ActiveSheet.PivotTables("PivotTable21").PivotFields("Count of QTY")
        .Caption = "Sum of QTY"
        .Function = xlSum
    End With
    ActiveWorkbook.ShowPivotTableFieldList = False
End Sub
§@ªÌ: Andy2483    ®É¶¡: 2024-2-21 15:14

¦^´_ 24# 198188


    ÁÂÁ«e½ú¦^´_
¦Ü©ó·s´£¥Xªº¼Ï¯Ã°ÝÃD»Ý¨D»P¦¹¥DÃD®t²§¤j,«Øij«e½ú¦AµZ¿i¤@¤U,¦pªGÁÙ¨Sªk¸Ñ¨M ¥tµo·s¸ÜÃDµ¹ª©¤W«e½ú¤@°_°µ¥æ¬y
§@ªÌ: 198188    ®É¶¡: 2024-2-21 15:34

¦^´_ 25# Andy2483


    ¦nªº¡AÁÂÁ¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-22 13:04

¥»©«³Ì«á¥Ñ Andy2483 ©ó 2024-2-22 13:06 ½s¿è

¦^´_ 24# 198188

ÁÂÁ½׾Â,ÁÂÁ«e½ú
¤µ¤Ñ½Æ²ß¤F¤@¤U,¾Ç²ß¤ß±o¦p¤U,½Ð«e½ú°Ñ¦Ò,½Ð¦U¦ì«e½ú«ü±Ð
§tµù¸Ñ¦r¼Æ¤Ó¦h¤À¦¨¨â­¶
Option Explicit
Sub TEST()
Dim Brr(1 To 100, 1 To 14), A, Z, Q, P, i&, j%, R&, C%, N&, x%, T$, T14$, T15$, T5$, V8&, V9&, V10#, Tp1$, Tp3$, Tp5$, Y&, SS$, Tts#
Dim PGNr, Rackr, Itemr, PGr, DPLs As Worksheet, xR As Range, xRs As Range, TT$, TH#, RH, Sh#, xRc As Range, xRe As Range
'¡ô«Å§iÅܼÆ,%¬Oµu¾ã¼Æ,&¬Oªø¾ã¼Æ,$¬O¦r¦êÅܼÆ,#¬OÂùºë«×¤p¼Æ,As Range¬OÀx¦s®æÅܼÆ,As Worksheet¬O¤u§@ªíÅܼÆ,¨ä¥¦¨S¦³«ü©wªº¬O³q¥Î«¬ÅܼÆ
Set Z = CreateObject("Scripting.Dictionary"): Application.ScreenUpdating = False: Application.DisplayAlerts = False: Sh = Rows(17).RowHeight / 32
'¡ô¥OZÅܼƬO ¦r¨å:¥O¿Ã¹õ¼È¤£ÀHµ{§Ç°µÅܤÆ:¥Oµ{§Ç¤£­n¸õ¥X(¦X¨ÖÀx¦s®æ¥u¯d¥ª¤W®æ¤º®e)ªº¸ß°Ýµ¡,¥OShÅܼƬO²Ä17¦C¦C°ª/32 ­È
Tts = [O1]: PGNr = [PGN!A1].CurrentRegion: Rackr = [Rack!A1].CurrentRegion: Itemr = [Item!A1].CurrentRegion: PGr = [PG!A1].CurrentRegion
'¡ô¥OTtsÅܼƬO[O1]Àx¦s®æ­È,¥OPGNrÅܼƬO¤u§@ªí("PGN").[A1]Àx¦s®æ¬Û¾F¦êÁp«áÂX®i¦¨ªº³Ì¤p¤è¥¿°Ï°ìÀx¦s®æ­È±a¤Jªº¤Gºû°}¦C,Rackr/Itemr/PGrÅܼƨ̦¹Ãþ±À
Set DPLs = Sheets("DPL"): DPLs.Activate: T = [J3]: DPLs.UsedRange.Offset(19).EntireRow.Delete: Set xR = [A20]
'¡ô¥ODPLsÅܼƬO¤u§@ªí("DPL"),¥ODPLs¿E¬¡,¥OT³o¦r¦êÅܼƬO[J3]Àx¦s®æ­È(Invoice No),¥OªíÀY¥H¤Uªº¸ê®Æ¦C¾ã¦C§R°£,¥OxR³oÀx¦s®æÅܼƬO [A20]Àx¦s®æ
Cells.VerticalAlignment = xlCenter: ActiveSheet.ResetAllPageBreaks: [A1].Activate: For i = 1 To 19: TH = TH + Rows(i).RowHeight: Next
'¡ô¥O¥þ³¡Àx¦s®æ®æ¦¡««ª½¦V¤å¦r¸m¤¤,¥O²M°£¤À­¶½u,¥O´å¼Ð¸õ¨ì[A1],³]¶¶°j°é±N1¨ì19¦Cªº¦C°ª¬Û¥[µ¹ THÅܼÆ
For i = 2 To UBound(PGr)
'¡ô³]¶¶°j°é!¥Oi±q2 ¨ìPGr°}¦C³Ì¤j¯Á¤Þ¦C¸¹
   If Z(PGr(i, 1) & "^") = "" Then Z(PGr(i, 1) & "^") = PGr(i, 2) Else MsgBox "PGªí " & PGr(i, 1) & " ­«½Æ": Exit Sub
   '¡ô¦pªGi°j°é¦C1ÄæPGr°}¦C­È³s±µ"^"²Å¸¹©Ò²Õ¦¨ªº·s¦r¦ê¬dZ¦r¨å¦^¶Çitem¬OªÅ¦r¤¸!´N¥O¨äitem­È¬O i°j°é¦C2ÄæPGr°}¦C­È,
   '§_«h¥NªíPGªíªº¹ï·Ó¸ê®Æ¦³­«½Æ, ¸õ¥X´£¥Üµ¡~~,³Ì«áµ²§ôµ{¦¡°õ¦æ

Next
For i = 2 To UBound(Rackr)
'¡ô³]¶¶°j°é!¥Oi±q2 ¨ìRackr°}¦C³Ì¤j©Ò¤Þ¦C¸¹
   If Rackr(i, 11) <> T Then GoTo i01
   '¡ô¦pªGi°j°é¦C11ÄæRackr°}¦C­È¤£¦P©óTÅܼÆ(Invoice No),´N¸õ¨ì¼Ð¥Üi01¦ì¸mÄ~Äò°õ¦æ
   T14 = Rackr(i, 14): T5 = Rackr(i, 5): T15 = Rackr(i, 15)
   '¡ô¥OT14³o¦r¦êÅܼƬOi°j°é¦C14ÄæRackr°}¦C­È,T5/T15¨Ì¦¹³W«hÃþ±À
   If Not Z.Exists(T15) Then R = N Mod 3 + 1: C = N \ 3: N = N + 1: Brr(R, Array(1, 3, 4)(C)) = T15: Z(T15) = ""
   '¡ô¦pªGZ¦r¨å¸Ì¨S¦³T15ÅܼÆkey!´N¥ORÅܼƭȬO(NÅܼư£3ªº¾l¼Æ+1),¥ONÅܼƲ֥[1,¥OT15ÅܼƼg¤JBrr°}¦C¤¤,¥OT15¦bZ¦r¨å¹ïÀ³item¬OªÅ¦r¤¸
   If InStr("," & Z(T14 & "/GD") & ",", "," & T15 & ",") = 0 Then Z(T14 & "/GD") = Z(T14 & "/GD") & "," & T15
   '¡ô¦pªGT14ÅܼƳs±µ"/GD"¦r¦ê©Ò²Õ¦¨·s¦r¦êkey¬dZ¦r¨å±oitem­È¦AÀY§À³s±µ³r¸¹©Ò²Õ¦¨ªº·s¦r¦ê¸Ì¨S¦³ T15ÅܼÆÀY§À³s±µ³r¸¹©Ò²Õ¦¨ªº·s¦r¦ê!
   '´N¥O¸Óitem¦r¦ê¥H³r¸¹³s±µT15Åܼƫá,©ñ¦^Z¦r¨å¤¤

   If InStr("," & Z(T14 & "/RN") & ",", "," & T5 & ",") = 0 Then Z(T14 & "/RN") = Z(T14 & "/RN") & "," & T5: Z(T5 & "|") = i Else MsgBox "Rackªí " & T5 & " ­«½Æ": Exit Sub
   '¡ô¦pªGT14ÅܼƳs±µ"/RN"¦r¦ê©Ò²Õ¦¨·s¦r¦êkey¬dZ¦r¨å±oitem­È¦AÀY§À³s±µ³r¸¹©Ò²Õ¦¨ªº·s¦r¦ê¸Ì¨S¦³ T5ÅܼÆÀY§À³s±µ³r¸¹©Ò²Õ¦¨ªº·s¦r¦ê!
   '´N¥O¸Óitem¦r¦ê¥H³r¸¹³s±µT5Åܼƫá,©ñ¦^Z¦r¨å¤¤,¥OT5ÅܼƳs±µ"|"²Å¸¹©Ò²Õ¦¨ªº·s¦r¦ê·íkey,item¬O¦C¸¹,¯Ç¤JZ¦r¨å¤¤,
   '§_«h¥NªíRack¤u§@ªí ²Ä5Äæ¸ÌªºRack Number¦³­«½Æ,¥O¸õ¥X´£µøµ¡~~~,,³Ì«áµ²§ôµ{¦¡°õ¦æ

i01: Next
DPLs.[G12].Resize(3, 4) = Brr: DPLs.[G15] = "TOTAL " & N & " X 45'HC CONTAINER": N = 0
'¡ô¥ODPLsÅܼÆ[G12]Àx¦s®æÂX®i¦V¤U3¦C,¦V¥kÂX®i4Äæ½d³òªºÀx¦s®æ­È¥HBrr°}¦C­È¼g¤J
For i = 2 To UBound(PGNr)
'¡ô³]¶¶°j°é!¥Oi±q2 ¨ìPGNr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
   If PGNr(i, 1) <> T Then GoTo i02
   '¡ô¦pªGi°j°é¦C1ÄæPNGr°}¦C­È¤£¦P©óTÅܼÆ(Invoice No),´N¸õ¨ì¼Ð¥Üi02¦ì¸mÄ~Äò°õ¦æ
   If Z.Exists(PGNr(i, 2) & "/GD") Then Z(PGNr(i, 2) & "/GD") = "CONTAINER NO.:" & Mid(Z(PGNr(i, 2) & "/GD"), 2) & vbCrLf & PGNr(i, 3)
   '¡ô¦pªGi°j°é¦C2ÄæPNGr°}¦C­È³s±µ"/GD"¦r¦ê©Ò²Õ¦¨ªº·s¦r¦ê¦bZ¦r¨å¸Ì¦³¦¹key!´N¥Oitem´«¬°·s²Õ¦X¦¨ªº¦r¦ê
i02: Next
For i = 2 To UBound(Itemr)
'¡ô³]¶¶°j°é!¥Oi±q2 ¨ìItemr°}¦CÁa¦V³Ì¤j¯Á¤Þ¦C¸¹
   If Z.Exists(Itemr(i, 3) & "|") Then Z(Itemr(i, 3) & "|") = Z(Itemr(i, 3) & "|") & "," & i
   '¡ô¦pªG¥Hi°j°é¦C3ÄæItemr°}¦C­È³s±µ"|"²Å¸¹©Ò²Õ¦¨ªº·s¦r¦ê¬dZ¦r¨å¦³¦¹key!´N¥Oitem¥H³r¸¹³s±µiÅܼÆ(¦C¸¹)²Õ¦¨·s¦r¦ê©ñ¦^Z¦r¨å¤¤
Next
§@ªÌ: Andy2483    ®É¶¡: 2024-2-22 13:04

For Each A In Z.KEYS
'¡ô³]³v¶µ°j°é!¥OAÅܼƬOZ¦r¨å¤¤ªºkey
   If Right(A, 3) <> "/RN" Then GoTo A01 Else Q = Split(Z(A), ","): xR = Z(Split(A, "/RN")(0) & "/GD")
   '¡ô¦pªGAÅܼƥk3¦r¤£¬O"/RN"¦r¦ê!´N¥Oµ{§Ç¸õ¨ì¼Ð¥ÜA01¦ì¸mÄ~Äò°õ¦æ,
   '§_«h´N¥OQÅܼƬO¥H³r¸¹¤À³Î¦r¦ê(¥HAÅܼƬdZ¦r¨å¦^¶Çªº¦r¦ê)©Ò§Î¦¨ªº¤@ºû°}¦C,¥OxRÀx¦s®æ­È¬O¬dZ¦r¨å¦^¶Ç­È

   With xR.Resize(, 14): .Merge: .Font.Size = 9: .Font.Bold = True: .Rows.RowHeight = 52 * Sh: End With
   '¡ô¥OCONTAINER NO¼ÐÃD®æ¦X¨Ö,¤å¦r¤j¤p9,³]¤å¦r²ÊÅé,¦C°ª52­Ó³æ¦ì
   For i = 1 To UBound(Q)
   '¡ô³]¶¶°j°é!¥Oi±q1 ¨ìQ°}¦C³Ì¤j¯Á¤Þ¸¹
      Set xR = xR(2): xR.Resize(1, 14).Interior.ColorIndex = 15: xR.Resize(1, 14).Font.Bold = True: xR.Rows.RowHeight = 27 * Sh
      '¡ô¥OxRÀx¦s®æÅܬ°¤U¤@®æ,¥O±qxRÀx¦s®æ¥kÂX®i14®æ½d³òÀx¦s®æ©³¦â¬°¦Ç¦â/¤å¦r¬°²ÊÅé,¦C°ª27­Ó³æ¦ì
      With xR.Resize(1, 4): .Merge: .Font.Size = 12:  .Value = "'" & Q(i): End With
      '¡ô¥O±qxRÀx¦s®æ¥kÂX®i14®æ½d³òÀx¦s®æ¦X¨Ã/¤å¦r¤j¤p12/¥O¤å¦r¤º®e¬°i°j°éQ°}¦C­È(«e­±¥[³æ¤Þ¸¹¬O¥O±j¨î¨ä¬°¤å¦r)
      xR(1, 6).Resize(, 2).Merge: xR(1, 10).Resize(, 5).Merge
      '¡ô¥O¬q¸¨Àx¦s®æ¦X¨Ö
      P = Split(Z(Q(i) & "|"), ","): R = Val(P(0))
      '¡ô¥OPÅܼƬO¥H³r¸¹¤À³Î¦r¨å¸Ì°O¿ýªºItemªí¦C¸¹¦ê,¥ORÅܼƬORackªíªº¦C¸¹
      xR(1, 8) = Val(Rackr(R, 6)): xR(1, 9) = Val(Rackr(R, 7)): xR(1, 10) = Rackr(R, 8) & " x " & Rackr(R, 9) & " x " & Rackr(R, 10)
      '¡ô¥O¦ÛxRÀx¦s®æ¥k8®æ(H)Àx¦s®æ­È¬ORÅܼƦC6ÄæRackr°}¦C­È,¥O¦ÛxRÀx¦s®æ¥k9®æ(I)Àx¦s®æ­È¬ORÅܼƦC9ÄæRackr°}¦C­È,
      '¥O¦ÛxRÀx¦s®æ¥k10®æ(H)Àx¦s®æ­È¬ORÅܼƦC8/9/10ÄæRackr°}¦C­È¥H"x"²Å¸¹³s±µ©Ò²Õ¦¨ªº·s¦r¦ê

      V8 = V8 + xR(1, 8): V9 = V9 + xR(1, 9): V10 = V10 + (Val(Rackr(R, 8)) * Val(Rackr(R, 9)) * Val(Rackr(R, 10)) / 10 ^ 9): Set xRs = xR(2, 1)
      '¡ô¥OV8ÅܼƲ֥[ ¦ÛxRÀx¦s®æ¥k8®æ(H)Àx¦s®æ­È,¥OV9ÅܼƲ֥[ ¦ÛxRÀx¦s®æ¥k9®æ(H)Àx¦s®æ­È,¥OV10ÅܼƬOªø*¼e*°ª­È,¥OxRsÅܼƬOxRÀx¦s®æªº¤U¤@®æÀx¦s®æ
      For j = 1 To UBound(P)
      '¡ô³]¶¶°j°é!¥OjÅܼƱq1 ¨ìP°}¦C³Ì¤j¯Á¤Þ¸¹
         Tp1 = Itemr(P(j), 5): Tp3 = Z(Itemr(P(j), 6) & "^"): Tp5 = Itemr(P(j), 4)
         '¡ô¥OTp1¬O ItemªíItem Number­È,¥OTp3¬O¥H ItemªíItem Description Group­È¹ï·ÓGPªí±o¨ìªº Description
         Y = Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5)
         '¡ô¥OYÅܼƬO 5­ÓÃöÁä¦r¦ê¥H"/"²Å¸¹³s±µ°_¨Óªº¦r¦ê¬dZ¦r¨å¦^¶Ç­È
         If Y = 0 Then
         '¡ô¦pªGYÅܼƬO 0
            Set xR = xR(2): xR.Resize(1, 14).Font.Size = 9: xR = Tp1: xR(1, 3) = Tp3: xR(1, 5) = Tp5: xR(1, 6) = Val(Itemr(P(j), 7))
            '¡ô¥OxRÀx¦s®æÅܧ󬰤U¤@®æÀx¦s®æ,¥O±qxRÀx¦s®æ¥kÂX®i14®æ½d³òÀx¦s®æ¤å¦r¤j¤p9,¥OxRÀx¦s®æ­È¬O Tp1ÅܼƭÈ,¥OxRÀx¦s®æ¥k3®æ­È¬O Tp3ÅܼƭÈ,
            '¥OxRÀx¦s¥k5®æ­È¬O Tp5ÅܼƭÈ,¥OxRÀx¦s¥k6®æ­È¬O Itemªíªº Quantity­È

            Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5) = xR.Row: xR.Rows.RowHeight = 27 * Sh: GoTo j01
            '¡ô¥OYÅܼƬO 5­ÓÃöÁä¦r¦ê¥H"/"²Å¸¹³s±µ°_¨Óªº¦r¦ê·íkey,item¬OxRÀx¦s®æ¦C¸¹,¥OxRÀx¦s®æ·í¦C¦C°ª¬O27­Ó³æ¦ì,¥O¸õ¨ì¼Ð¥Üj01¦ì¸mÄ~Äò°õ¦æ
         End If
         Cells(Y, 6) = Cells(Y, 6) + Val(Itemr(P(j), 7))
         '¡ô¥OYÅܼƦCFÄæÀx¦s®æ­È²Ö¥[ Itemªíªº Quantity­È
j01:  Next
      With Range(xRs, xR(1, 14))
      '¡ô¥H¤U¬OÃö©óxRsÀx¦s®æ¦Ü xRÀx¦s®æ¥k14®æ¤§¶¡½d³òÀx¦s®æ
         .Sort KEY1:=.Item(6), Order1:=1, Header:=2: .Sort KEY1:=.Item(5), Order1:=1, Key2:=.Item(3), Order2:=1, Key3:=.Item(1), Order2:=1, Header:=2
         '¡ô¥O¸Ó½d³òÀx¦s®æ°µ¤T¼h¦¸µL¼ÐÃDªº¶¶±Æ§Ç
         For R = 1 To .Rows.Count: .Cells(R, 1).Resize(1, 2).Merge: .Cells(R, 3).Resize(1, 2).Merge: .Cells(R, 6).Resize(1, 2).Merge: .Cells(R, 8).Resize(1, 7).Merge: Next
         '¡ô³]¶¶°j°é!¥ORÅܼƱq1 ¨ì¸Ó°Ï°ìªº¦C¼Æ,¥O¦U°Ï¬qÀx¦s®æ¦X¨Ö
      End With
   Next
   Set xR = xR(2)
   '¡ô¥OxRÀx¦s®æÅܧ󬰤U¤@®æÀx¦s®æ
A01: Next
Cells.VerticalAlignment = xlCenter: If ActiveSheet.VPageBreaks.Count + 1 = 2 Then ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
'¡ô¥O¥þ³¡Àx¦s®æ®æ¦¡««ª½¤è¦V¤å¦r¸m¤¤,'¡ô¦pªG¦C¦L½d³òªº¾î¦V­¶¼Æ¬O2! ´N¥OÁa¦V¤À­¶½u²¾¦Ü³Ì¥k°¼,Åý¾î¦V­¶¼Æ¬O1,¦Û°Ê½Õ¾ã¨ä¥L°t¦X¦C¦L°Ñ¼Æ
https://forum.twbts.com/viewthread.php?tid=19505
xR(1, 5) = "TOTAL": xR.Resize(, 4).Merge: xR(1, 5).Resize(, 3).Merge: xR(1, 8) = V8: xR(1, 9) = V9: xR(1, 10) = Round(V10, 2): xR(1, 10).Resize(1, 5).Merge: xR.Rows.RowHeight = 27 * Sh
'¡ô¥OxRÀx¦s®æ¥k5®æÀx¦s®æ­È¬O "TOTAL" ¦r¦ê,«e4®æ½d³ò¦X¨ÖÀx¦s®æ,¥k5®æ¶}©lÂX®i¥k3®æ½d³ò¦X¨ÖÀx¦s®æ,¥O¶ñ¤J²Î­p­È¨Ã¥B¦X¨ÖÀx¦s®æ,¥O¦C°ª¬O27­Ó³æ¦ì
With xR.Resize(1, 14): .Font.Size = 12: .Font.Bold = True: End With
'¡ô¥OxRÀx¦s®æÂX®i¥k14®æ½d³ò¤å¦r¤j¤p¬°12 / ²ÊÅé
ActiveSheet.Names.Add Name:="PrintArea", RefersTo:=Range([A1], xR(, 14)): ActiveSheet.PageSetup.PrintArea = "PrintArea"
'¡ô¥OÀx¦s®æ½d³ò«Ø¥ß¦WºÙ¬° "PrintArea",¥O¦C¦L½d³ò¬°¦WºÙ "PrintArea"
For i = 20 To xR.Row '800-327.3=472.7 : 472.7/327.3=1.44
'¡ô³]¶¶°j°é¥OiÅܼƱq20¨ì xRÀx¦s®æ¦C¸¹
   TT = Cells(i, 3) & "/" & Cells(i, 5)
   '¡ô¥OTTÅܼƬOi°j°é¦CCÄæ­È»Pi°j°é¦CEÄæ­È¥H"/"²Å¸¹³s±µ²Õ¦¨ªº·s¦r¦ê
   If TT = "/" Then GoTo i03
   '¡ô¦pªGTTÅܼƬO "/"²Å¸¹!´N¥Oµ{§Ç¸õ¨ì¼Ð¥Üi03¦ì¸mÄ~Äò°õ¦æ
   If TT = SS Or SS = "" Then
   '¡ô¦pªGTTÅܼƦPSSÅÜ¼Æ ©ÎSSÅܼƬOªÅ¦r¤¸??
      If xRc Is Nothing Then Set xRc = Cells(i, 3): Set xRe = Cells(i, 5) Else Set xRc = Union(xRc, Cells(i, 3)): Set xRe = Union(xRe, Cells(i, 5))
      '¡ô¦pªGxRcÀx¦s®æ¬OªÅªº!´N¥OxRcÀx¦s®æ¬Oi°j°é¦CCÄæÀx¦s®æ,¥OxReÀx¦s®æ¬Oi°j°é¦CEÄæÀx¦s®æ,
      '§_«h´N¥Oi°j°é¦CCÄæÀx¦s®æ¯Ç¤JxRcÀx¦s®æ¶°¤§¤¤,¥Oi°j°é¦CEÄæÀx¦s®æ¯Ç¤JxReÀx¦s®æ¶°¤§¤¤

   End If
i03: RH = RH + Cells(i, 1).RowHeight
     '¡ô¥ORHÅܼƲ֥[°j°é¦C°ª
   If Cells(i + 1, 3) & "/" & Cells(i + 1, 5) <> TT Or RH / TH > Tts Then
   '¡ô¦pªG(i+1)°j°é¦CCÄæ­È»P(i+1)°j°é¦CEÄæ­È¥H"/"²Å¸¹³s±µ²Õ¦¨ªº·s¦r¦ê¤£¦P©ó TTÅܼƩΠRHÅܼư£¥HTHÅܼƪº°Ó > TtsÅܼÆ??
      If Not xRc Is Nothing Then
      '¡ô¦pªGxRcÀx¦s®æ¦³ª«¥ó??
         If xRc.Count > 1 Then With Intersect(xRc, xRc.Offset(1)): .Merge: .Value = "": End With: xRe.Merge: xRe.VerticalAlignment = xlTop: xRc.Offset(, 5).Merge
         '¡ô¦pªGxRcÀx¦s®æ¼Æ¤j©ó1!´N¥OxRcÀx¦s®æ¶°°Ï°ì²Ä1¦C(¤£§t)¥H¤UªºÀx¦s®æ°µ¦X¨Ö,¥OxReÀx¦s®æ¶°°µ¦X¨Ö,¤å¦r°¾¤W
      End If
      Set xRc = Nothing: Set xRe = Nothing: SS = Cells(i + 1, 3) & "/" & Cells(i + 1, 5)
      '¡ô¥OxRc xReÅܼƲMªÅ,¥OSSÅܼƬO (i+1)°j°é¦CCÄæ­È»P(i+1)°j°é¦CEÄæ­È¥H"/"²Å¸¹³s±µ²Õ¦¨ªº·s¦r¦ê
   End If
   If RH / TH > Tts Then Cells(i + 1, 1).PageBreak = xlPageBreakManual: RH = 0
   '¡ô¦pªGRH / TH°Ó¤j©ó Tts!´N¥O¦bi+1¦C³]©w¤À­¶½u,¥ORHÅܼÆÂk¹s
Next
Intersect(Range("PrintArea"), Range("PrintArea").Offset(19)).Borders.LineStyle = 1
'¡ô¥OªíÀY¥H¥~ªº¸ê®Æ®æ³]©w²Ó®Ø½u
Set Z = Nothing: Erase PGNr, Rackr, Itemr, PGr: Set xR = Nothing: Set xRs = Nothing: Set xRc = Nothing: Set xRe = Nothing
End Sub
§@ªÌ: 198188    ®É¶¡: 2024-2-22 13:53

¦^´_ 28# Andy2483


    ÁÂÁ¡A«e½ú«üÂI¡C
§@ªÌ: 198188    ®É¶¡: 2024-2-26 09:37

¥»©«³Ì«á¥Ñ 198188 ©ó 2024-2-26 09:38 ½s¿è

[attach]37491[/attach]¦^´_ 28# Andy2483


§Ú¤µ¤Ñ¸Õ¤F¤@­Ó·sªº¡A¥X²{¬õ¦â³¡¤Àªº°ÝÃD¡C
¥ªÃä¶Â¦â¦rªº¬OVBA°õ¦æ¥X¨Óªº¡A¥kÃ䪺¬O·Q­nªºµ²ªG¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-26 11:07

¦^´_ 30# 198188

ÁÂÁ«e½ú¦^´_
¼W¥[ Àˬd"PGN"ªí¸ê®Æ¬O§_¦³ Invoice No,°õ¦æµ²ªG
[attach]37492[/attach]

For i = 2 To UBound(PGNr)
   Z(PGNr(i, 1)) = "/" '20240226·s¼W
   If PGNr(i, 1) <> T Then GoTo i02
   If Z.Exists(PGNr(i, 2) & "/GD") Then
      Z(PGNr(i, 2) & "/GD") = "CONTAINER NO.:" & Mid(Z(PGNr(i, 2) & "/GD"), 2) & vbCrLf & PGNr(i, 3)
   End If
i02: Next
If Z(T) <> "/" Then MsgBox "PGNªí¨S¦³ " & T & " ¶µ¥Ø": Exit Sub   '20240226·s¼W
For i = 2 To UBound(Itemr)
   If Z.Exists(Itemr(i, 3) & "|") Then Z(Itemr(i, 3) & "|") = Z(Itemr(i, 3) & "|") & "," & i
Next
§@ªÌ: 198188    ®É¶¡: 2024-2-26 11:34

¦^´_ 31# Andy2483


    ¥[¦b­þ­Ó¦ì¸m¡H³Ì«á¶Ü¡H
§@ªÌ: 198188    ®É¶¡: 2024-2-26 14:09

¦^´_ 31# Andy2483
¤§«e¤W¸ü¿ù¤Fªþ¥ó¡A³o­Óªþ¥ó¬O¹B¦æ¦Z³B²zªº®ÄªG¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-26 14:17

¦^´_ 33# 198188


    PGNªí¸Ì´N¬O¨S¦³ C864-2024 ³o¸ê®Æ,¤£ª¾©Ò¤ª
§@ªÌ: 198188    ®É¶¡: 2024-2-26 14:27

¦^´_ 34# Andy2483


    ¤£¦n·N«ä¡A¥[¤F¡A¥ª¤W¨¤°ÝÃD¤£¦s¦b¡A¥k¤U¤èTOTAL¨º­Ó¦a¤èªº°ÝÃDÁÙ¬O¦s¦b¡C
§@ªÌ: Andy2483    ®É¶¡: 2024-2-26 15:07

¦^´_ 30# 198188


    «Å§i¸Ìªº V8&, V9& §ï¬° V8#, V9#
§@ªÌ: 198188    ®É¶¡: 2024-2-26 15:20

¦^´_ 36# Andy2483


    Dim Brr(1 To 100, 1 To 14), A, Z, Q, P, i&, j%, R&, C%, N&, x%, T$, T14$, T15$, T5$, V8#, V9#, V10#, Tp1$, Tp3$, Tp5$, Y&, SS$, Tts#
­×§ï¤F¡AÁÙ¦³¬õ¦â¦r¨â³B°ÝÃD¡C
[attach]37503[/attach]
§@ªÌ: Andy2483    ®É¶¡: 2024-2-26 15:36

¦^´_ 37# 198188

HÄæ¾ãÄæ¿ï¨ú¥kÁä >Àx¦s®æ®æ¦¡:
[attach]37504[/attach]

¦Ü©ó¦X­p10,½Ð¦Û¤v¸Õ¸Õ,27#¦³µù¸Ñ,¤@°_¾Ç²ß
§@ªÌ: 198188    ®É¶¡: 2024-2-26 18:03

¦^´_ 38# Andy2483

¦X­p10¸Ñ¨M¤F¡A¤£¹L889´Nºâ¦b¥~­±Àx¦s®æ½Õ®Õ¤F®æ¦¡¡A¦ý¬O¹B¦æVBA¦Z¡AÁÙ¬O¤@¼ËÅܦ¨¾ã¼Æ¡C

    Sub TEST()
Dim Brr(1 To 100, 1 To 14), W, A, Z, Q, P, i&, j%, R&, C%, N&, x%, T$, T14$, T15$, T5$, V6#, V8#, V9#, V10#, Tp1$, Tp3$, Tp5$, Y&, SS$, Tts#
Dim PGNr, Rackr, Itemr, PGr, DPLs As Worksheet, xR As Range, xRs As Range, TT$, TH#, ii, RH, Sh#, xRc As Range, xRe As Range
Set Z = CreateObject("Scripting.Dictionary"): Application.ScreenUpdating = False: Application.DisplayAlerts = False: Sh = Rows(17).RowHeight / 32
Tts = [O1]: PGNr = [PGN!A1].CurrentRegion: Rackr = [Rack!A1].CurrentRegion: Itemr = [Item!A1].CurrentRegion: PGr = [PG!A1].CurrentRegion
Set DPLs = Sheets("DPL"): DPLs.Activate: T = [J3]: DPLs.UsedRange.Offset(19).EntireRow.Delete: Set xR = [A20]
Cells.VerticalAlignment = xlCenter: ActiveSheet.ResetAllPageBreaks: [A1].Activate: For i = 1 To 19: TH = TH + Rows(i).RowHeight: Next
For i = 2 To UBound(PGr)
   If Z(PGr(i, 1) & "^") = "" Then Z(PGr(i, 1) & "^") = PGr(i, 2) Else MsgBox "PGªí " & PGr(i, 1) & "REPEAT": Exit Sub
Next
For i = 2 To UBound(Rackr)
   If Rackr(i, 11) <> T Then GoTo i01
   T14 = Rackr(i, 14): T5 = Rackr(i, 5): T15 = Rackr(i, 15)
   If Not Z.Exists(T15) Then R = N Mod 3 + 1: C = N \ 3: N = N + 1: Brr(R, Array(1, 3, 4)(C)) = T15: Z(T15) = ""
   If InStr("," & Z(T14 & "/GD") & ",", "," & T15 & ",") = 0 Then Z(T14 & "/GD") = Z(T14 & "/GD") & "," & T15
   If InStr("," & Z(T14 & "/RN") & ",", "," & T5 & ",") = 0 Then Z(T14 & "/RN") = Z(T14 & "/RN") & "," & T5: Z(T5 & "|") = i Else MsgBox "Rack Sheet" & T5 & "REPEAT": Exit Sub
i01: Next
DPLs.[G12].Resize(3, 4) = Brr: DPLs.[G15] = "TOTAL " & N & " X 45'HC CONTAINER": N = 0
For i = 2 To UBound(PGNr)
   If PGNr(i, 1) <> T Then GoTo i02
   If Z.Exists(PGNr(i, 2) & "/GD") Then Z(PGNr(i, 2) & "/GD") = "CONTAINER NO.:" & Mid(Z(PGNr(i, 2) & "/GD"), 2) & vbCrLf & PGNr(i, 3)
i02: Next
For i = 2 To UBound(Itemr)
   If Z.Exists(Itemr(i, 3) & "|") Then Z(Itemr(i, 3) & "|") = Z(Itemr(i, 3) & "|") & "," & i
   
Next
For Each A In Z.KEYS
   If Right(A, 3) <> "/RN" Then GoTo A01 Else Q = Split(Z(A), ","): xR = Z(Split(A, "/RN")(0) & "/GD")
   With xR.Resize(, 14): .Merge: .Font.Size = 9: .Font.Bold = True: .Rows.RowHeight = 52 * Sh: End With
   For i = 1 To UBound(Q)
      Set xR = xR(2): xR.Resize(1, 14).Interior.ColorIndex = 15: xR.Resize(1, 14).Font.Bold = True: xR.Rows.RowHeight = 27 * Sh
      With xR.Resize(1, 4): .Merge: .Font.Size = 12:  .Value = "'" & Q(i): End With
      xR(1, 6).Resize(, 2).Merge: xR(1, 10).Resize(, 5).Merge
      P = Split(Z(Q(i) & "|"), ","): R = Val(P(0))
      xR(1, 8) = Val(Rackr(R, 6)): xR(1, 9) = Val(Rackr(R, 7)): xR(1, 10) = Rackr(R, 8) & " x " & Rackr(R, 9) & " x " & Rackr(R, 10)
      V8 = V8 + xR(1, 8): V9 = V9 + xR(1, 9): V10 = V10 + (Val(Rackr(R, 8)) * Val(Rackr(R, 9)) * Val(Rackr(R, 10)) / 10 ^ 9): Set xRs = xR(2, 8): Set xRs = xR(2, 1)
      For j = 1 To UBound(P)
         Tp1 = Itemr(P(j), 5): Tp3 = Z(Itemr(P(j), 6) & "^"): Tp5 = Itemr(P(j), 4): W = W + Itemr(P(j), 7)
         Y = Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5)
         If Y = 0 Then
            Set xR = xR(2): xR.Resize(1, 14).Font.Size = 9: xR = Tp1: xR(1, 3) = Tp3: xR(1, 5) = Tp5: xR(1, 6) = Val(Itemr(P(j), 7))
            Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5) = xR.Row: xR.Rows.RowHeight = 27 * Sh: GoTo j01
         End If
         Cells(Y, 6) = Cells(Y, 6) + Val(Itemr(P(j), 7))
j01:  Next
      With Range(xRs, xR(1, 14))
         .Sort KEY1:=.Item(6), Order1:=1, Header:=2: .Sort KEY1:=.Item(5), Order1:=1, Key2:=.Item(3), Order2:=1, Key3:=.Item(1), Order2:=1, Header:=2
         For R = 1 To .Rows.Count: .Cells(R, 1).Resize(1, 2).Merge: .Cells(R, 3).Resize(1, 2).Merge: .Cells(R, 6).Resize(1, 2).Merge: .Cells(R, 8).Resize(1, 7).Merge: Next
      End With
   Next
   Set xR = xR(2)
A01: Next
Cells.VerticalAlignment = xlCenter: If ActiveSheet.VPageBreaks.Count + 1 = 2 Then ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1
xR(1, 5) = "TOTAL:": xR(1, 6) = W: xR.Resize(, 4).Merge: xR(1, 6).Resize(, 2).Merge: xR(1, 8) = V8: xR(1, 9) = V9: xR(1, 10) = Round(V10, 2): xR(1, 10).Resize(1, 5).Merge: xR.Rows.RowHeight = 27 * Sh
With xR.Resize(1, 14): .Font.Size = 12: .Font.Bold = True: End With
ActiveSheet.Names.Add Name:="PrintArea", RefersTo:=Range([A1], xR(, 14)): ActiveSheet.PageSetup.PrintArea = "PrintArea"
For i = 20 To xR.Row '800-327.3=472.7 : 472.7/327.3=1.44
   TT = Cells(i, 3) & "/" & Cells(i, 5)
   If TT = "/" Then GoTo i03
   If TT = SS Or SS = "" Then
      If xRc Is Nothing Then Set xRc = Cells(i, 3): Set xRe = Cells(i, 5) Else Set xRc = Union(xRc, Cells(i, 3)): Set xRe = Union(xRe, Cells(i, 5))
   End If
i03: RH = RH + Cells(i, 1).RowHeight
   If Cells(i + 1, 3) & "/" & Cells(i + 1, 5) <> TT Or RH / TH > Tts Then
      If Not xRc Is Nothing Then
         If xRc.Count > 1 Then With Intersect(xRc, xRc.Offset(1)): .Merge: .Value = "": End With: xRe.Merge: xRe.VerticalAlignment = xlTop: xRc.Offset(, 5).Merge
      End If
      Set xRc = Nothing: Set xRe = Nothing: SS = Cells(i + 1, 3) & "/" & Cells(i + 1, 5)
   End If
   If RH / TH > Tts Then Cells(i + 1, 1).PageBreak = xlPageBreakManual: RH = 0
Next
Intersect(Range("PrintArea"), Range("PrintArea").Offset(19)).Borders.LineStyle = 1
Set Z = Nothing: Erase PGNr, Rackr, Itemr, PGr: Set xR = Nothing: Set xRs = Nothing: Set xRc = Nothing: Set xRe = Nothing
End Sub
§@ªÌ: Andy2483    ®É¶¡: 2024-2-27 08:34

¦^´_ 39# 198188

¼F®`,¥H¤U¬õ¦r¤]­n¥[,¥t¥~§ÚªºHÄæ¾ãÄæ(³s¦P«á¤èªºªÅ®æ)¿ï¨úÅܧó®æ¦¡¬°¤p¼Æ¨â¦ì«á,°õ¦æ´N·|±a¤p¼Æ889.00,½Ð¦A¸Õ¸Õ
For j = 1 To UBound(P)
         Tp1 = Itemr(P(j), 5): Tp3 = Z(Itemr(P(j), 6) & "^"): Tp5 = Itemr(P(j), 4): W = W + Itemr(P(j), 7)
         Y = Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5)
         If Y = 0 Then
            Set xR = xR(2): xR.Resize(1, 14).Font.Size = 9: xR = Tp1: xR(1, 3) = Tp3: xR(1, 5) = Tp5: xR(1, 6) = Val(Itemr(P(j), 7))
            Z(Q(i) & "/" & Tp1 & "/" & Tp3 & "/" & Tp5) = xR.Row: xR.Rows.RowHeight = 27 * Sh: GoTo j01
         End If
         Cells(Y, 6) = Cells(Y, 6) + Val(Itemr(P(j), 7)): W = W + Itemr(P(j), 7)
j01:  Next
§@ªÌ: 198188    ®É¶¡: 2024-2-27 09:33

¦^´_ 40# Andy2483


    ¥i¥H¤F¡AÁÂÁ«e½ú«üÂI¡C
½Ð°Ý¦pªG¥u¬O·QÅý¬Y­ÓÀx¦s®æ¡AÅã¥Ü¦h¤Ö­Ó¤p¼Æ¦ì¡AVBA«ç¼Ëªí¹F?
§@ªÌ: Andy2483    ®É¶¡: 2024-2-27 09:40

¦^´_ 41# 198188


    ¿ý»s¥¨¶°¸Õ¸Õ¬Ý,«Ü¦h¥N½X³£¥i¥H¿ý»s«á¦A²¤Æ´N¥i¥H¥Î¤F
§@ªÌ: 198188    ®É¶¡: 2024-2-27 09:46

¦^´_ 42# Andy2483


RANGE("A1").NumberFormatLocal = "0.00"
³o¼Ë¶Ü¡H




Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)