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

[µo°Ý] °õ¦æ¶¥¬q¿ù»~13

¸Õ¤@¤U³æ¦r¨å¤èªk
  1. Sub zz()
  2. Dim a, d As Object, c!, e!, b(9), ar, br, tr, kr, k, t, n&, kk, tt
  3. If [T7] = "" Then Exit Sub
  4. [x6].CurrentRegion.Offset(4).Clear
  5. Set d = CreateObject("scripting.dictionary")
  6. c = [ac4]
  7. e = [ac5]
  8. a = [n6].CurrentRegion
  9. ar = Array(8, 7, 6, 5)
  10. br = Array(0, 1, 3, 5)
  11. For i = 2 To UBound(a)
  12.     k = a(i, 7)
  13.     If Len(a(i, 2)) Then
  14.         kk = k & "|" & a(i, 2)
  15.         If Not d.exists(kk) Then
  16.             d(kk) = Array(a(i, 3), a(i, 4))
  17.         Else
  18.             t = d(kk)
  19.             t(0) = t(0) + a(i, 3)
  20.             d(kk) = t
  21.         End If
  22.     End If
  23.     b(8) = Join(Array(a(i, 1), a(i, 3), a(i, 4)), " ")
  24.     For j = 0 To UBound(br)
  25.         b(br(j)) = a(i, ar(j))
  26.     Next
  27.     b(2) = 1
  28.     If Not d.exists(k) Then
  29.         d(k) = b
  30.     Else
  31.         t = d(k)
  32.         n = 0
  33.         t(2) = t(2) + 1
  34.         For Each j In Array(3, 5)
  35.             t(j) = t(j) + b(j)
  36.             n = n + 1
  37.         Next
  38.         t(8) = t(8) & ", " & b(8)
  39.         d(k) = t
  40.     End If
  41. Next
  42. For i = 2 To UBound(a)
  43.     If Len(a(i, 2)) Then
  44.         k = a(i, 7)
  45.         kk = k & "|" & a(i, 2)
  46.         If d.exists(kk) Then
  47.             t = d(k)
  48.             tt = d(kk)
  49.             t(9) = t(9) & ", " & Join(Array(a(i, 2), tt(0), tt(1)))
  50.             d.Remove (kk)
  51.             d(k) = t
  52.         End If
  53.     End If
  54. Next
  55. t = d.items
  56. ReDim br(1 To d.Count, 1 To 10)
  57. ar = Array("PUMP MOTOR", "TOOLING")
  58. For i = 0 To UBound(t)
  59.     k = t(i)
  60.     For j = 0 To UBound(k)
  61.         br(i + 1, j + 1) = k(j)
  62.     Next
  63.     br(i + 1, 5) = Round(br(i + 1, 4) / e * c, 0)
  64.     n = IIf(InStr(br(i + 1, 10), "TOOLING"), 10, 2)
  65.     br(i + 1, 7) = br(i + 1, 6) + br(i + 1, 3) * n
  66.     br(i + 1, 10) = Mid(br(i + 1, 10), 3)
  67.     For jj = 0 To UBound(ar)
  68.         If InStr(br(i + 1, 10), ar(jj)) Then br(i + 1, 8) = ar(jj)
  69.     Next
  70.     If br(i + 1, 8) = "" Then br(i + 1, 8) = "MACHINE ACCESSORY"
  71. Next
  72. [x7].Resize(i, j) = br
  73. [x7].Resize(i, j).Borders.Weight = 1
  74. End Sub
½Æ»s¥N½X

TOP

¦^´_ 10# jesscc

¨º¬O T.cells(?, ?) ªº¥Îªk,
·í®æ T(1,1)
¥k¤@®æ T(1,2)
¥ª¤@®æ T(1,0)

TOP

­ã¤j¡A¯à§_¦AÀ°§Ú¬Ý¤@¤U¡A§Ú§ï¼g«á¤u§@ªí1ªº¸ê®Æ­nÂà¨ì¤u§@ªí2ªº¥N½X¡A¦]¬°¤ñ¸û¤Ö¥Î³o¼ËªºÂà¸ê®Æªk¡A©Ò¥H»yªk¤£¬O«ÜÀ´¡A°õ¦æ°_¨ÓÁöµM¨S°»¿ù¡A¦ý¬O¸ê®Æ¤]¨SÂন¡C
test2.rar (31.05 KB)
Jess

TOP

¦^´_ 13# jesscc

Sub A_To_B()
Dim mRow&, Crr, Y As Range, YR, C%
Set d = CreateObject("scripting.dictionary")
mRow = Sheets("¤u§@ªí2").[B500].End(xlUp).Row + 1
For Each Y In Range([Y7], [Y300].End(3))
d(Y & "") = Array(Y.Offset(, -1), Y, Y.Offset(, 6), Y.Offset(, 8), "", Y, "PKG", Y.Offset(, -1), Y.Offset(, 7), "", Y.Offset(, 3) / Y.Offset(, -1), Y.Offset(, 3), Y.Offset(, 4), Y.Offset(, 5))
If C = 0 Then C = UBound(d(Y & "")) + 1
Next

N = 0
¦r¨åÀɪºitem¬O°}¦C, ¥²¶·³v¤@½Õ¥Î
ReDim Crr(1 To d.Count, 1 To C)
For Each k In d.keys
    N = N + 1
    YR = d(k & "")
    For j = 1 To C: Crr(N, j) = YR(j - 1): Next
Next

With Sheets("¤u§@ªí2")
     .Range("B" & mRow).Resize(N, C).Value = Crr 'range«e¤Ö¤@­Ó "."
     .Activate
End With
End Sub

============================

TOP

¦^´_ 14# ­ã´£³¡ªL

ÁÂÁ­ã¤jªºÀ°¦£¡A§Ú¦A¦n¦n¬ã¨s¾Ç²ß¤@¤U¡C
Jess

TOP

¦^´_ 6# jesscc

¥u°w¹ï test.rar ¤ºªº¤¤ªº Transpose ºÃ°Ý¦^µª¦p¤U¡G
­Y¤£¥Î Transpose ¨Ó¸Ñ¡A¥i¥Î¤U¦C°j°é¤è¦¡¨Ó¼g¤J¡A¤£¹L¸ê®Æ¶q¦hªº¸Ü·|ªá¸û¦h®É¶¡¡C

­ì¦¡¡G
[AG7].Resize(d1.Count, 1) = Application.Transpose(d1.items)

§ï¬°¦p¤U¡G
s = d1.Items
For i = 0 To d1.Count - 1
    Cells(i + 7, 33).Value = s(i)
Next i

TOP

¦^´_ 16# Kubi
ÁÂÁÂK¤j¡A³o¼Ë§Ú´N¤£¥Î§ï¼g¥þ³¡ªºµ{¦¡¤F:'(
Jess

TOP

        ÀR«ä¦Û¦b : ¤H¨ÆªºÁ}Ãø»PµZ¿i¡A´N¬O¤@ºØ¦ÒÅç¡C
ªð¦^¦Cªí ¤W¤@¥DÃD