½Ð¨D§ï¨}µ{¦¡¡G
¤U±µ{¦¡¦³¤U±°ÝÃD¡G
1¡^ ¦pªGSheet1¦b BÄæ¨S¦³¸ê®Æªº¡A«á±CÄæ-FÄæ¸ê®Æ³£¤£·|Åã¥Ü¥X¨Ó¡C
2¡^ì³]p¨S¦³¤¤½c¤@¦æ
3¡^¸ê®Æ®w¿é¤J¦³®É·|¦³·L§ï
²{·Qקï¤ñ¸û²³æªº³W«h¡A¥uקï¹Ï¤ù³¡¤Àªº³W«h¡C
¹Ï¤ù¤U¤è¬O¸ê®Æ®w¡A¨CÓ³£©T©w¦³5¦æ¡A¦ý¤£©T©wÄæ¼Æ
¥ª¤W¹Ï¬°©T©w¼ÒªO¡A«ö·Ó¤U¤è¸ê®Æ®wªº¦ì¸m¡A±Æ¤J©T©w¼ÒªO¡C
¤À³Î¨âÄæ¡A
¦pªG¦³"SR" , ²Ä¤@Äæ©â¨úSR¶}©l¨ì "¡]" ©ÎªÌ ¡¨ ¡§ ªÅ®æ;
¦pªG¨S¦³"SR" ,²Ä¤@Äæ©â¨ú±q²Ä¤@Ó¦r¨ì ¡¨ ¡§ ªÅ®æ;
Á|¨Ò
"¤U¬[ SR1106(15F单¤¸)" ©â¨ú "SR1106"
"SR02 SM-057-094S (T-boltÁ³丝垫¤ù)" ©â¨ú "SR02"
"#2312302240 ªù®Ø¬Á¼þ 280MM =4PCS" ©â¨ú "#2312302240"
"W001 (OT3¤uµ{门¥É¬Á¼þGL1-008)" ©â¨ú "W001"
²Ä¤GÄæ©â¨ú²Ä¤@Äæ©â¨ú¦Zªº©Ò¦³¸ê®Æ¡A¦pªGÀY§À¬O¡§¡]¡¨¡§¡^¡¨´N¥h±¼
Á|¨Ò
"¤U¬[ SR1106(15F单¤¸)" ©â¨ú "15F单¤¸"
"SR02 SM-057-094S (T-boltÁ³丝垫¤ù)" ©â¨ú "SM-057-094S (T-boltÁ³丝垫¤ù"
"#2312302240 ªù®Ø¬Á¼þ 280MM =4PCS" ©â¨ú "ªù®Ø¬Á¼þ 280MM =4PCS"
"W001 (OT3¤uµ{门¥É¬Á¼þGL1-008)" ©â¨ú "OT3¤uµ{门¥É¬Á¼þGL1-008"
Sub Map()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim Brr, Crr, Ar, Arr, V, Z, A, i&, r&, C%, j%, T$, K$, Qs$, Qd$, No$, Mk$, Q$
For i = Worksheets.Count To 4 Step -1: Worksheets(i).Delete: Next
Set Z = CreateObject("Scripting.Dictionary")
Brr = Union(Sheets(1).UsedRange, Sheets(1).UsedRange.Offset(1))
Crr = Range(Sheets(2).[A1], Sheets(2).UsedRange): K = [B1]
For i = 1 To UBound(Brr) - 1
If InStr(Brr(i, 1), Left(K, 4)) = 0 Then GoTo i01
A = Split(Replace(Brr(i, 1), " ", " "), " "): Q = Mid(A(0), 5, 4): Qd = A(1)
If UBound(A) > 1 Then Qs = A(UBound(A)) Else Qs = ""
A = Z(Q): r = Z(Q & "/r"): C = 1
If Not IsArray(A) Then A = Crr: A(3, 2) = Q: A(3, 6) = Qs: A(3, 9) = Qd: A(4, 13) = Date: r = 5
r = r + 1: V = A(r, 2)
If InStr(Brr(i, 2), V) = 0 Or r = 10 Then GoTo i01
For j = 2 To UBound(Brr, 2)
C = C + 2: T = Trim(Brr(i, j)): If T = "" Then GoTo j01
If InStr(T, V) Then
A(r, C) = Mid(T, 4, 6): A(r, C + 1) = Replace(Mid(T, 11), ")", "")
Else
Ar = Split(T, Chr(10))
For Each Arr In Ar
If Not Split(Arr & " ", " ")(1) Like "[A-z][A-z]" Then GoTo j01
No = No & Chr(10) & Split(Arr, " ")(0)
Mk = Mk & Chr(10) & Mid(Arr, InStr(Arr, Split(Arr, " ")(1)))
Next
A(r, C) = Mid(No, 2): A(r, C + 1) = Mid(Mk, 2): No = "": Mk = ""
End If
j01: Next
Z(Q) = A: Z(Q & "/r") = r
i01: Brr(i + 1, 1) = IIf(Brr(i + 1, 1) = "", Brr(i, 1), Brr(i + 1, 1))
Next
If Z.Count = 0 Then Exit Sub
For Each A In Z.KEYS
If Not IsArray(Z(A)) Then GoTo A01
With Sheets(2).Copy(after:=Worksheets(Sheets.Count))
ActiveSheet.Name = A
[A1].Resize(UBound(Z(A)), UBound(Z(A), 2)) = Z(A)
End With
A01: Next
Application.Goto Sheets(1).[A1]
End Sub |