- ©«¤l
- 1446
- ¥DÃD
- 40
- ºëµØ
- 0
- ¿n¤À
- 1470
- ÂI¦W
- 0
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Excel 2010 & 2016
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2020-7-15
- ³Ì«áµn¿ý
- 2024-10-21
|
¦^´_ 5# Andy2483
ÁÂÁ½׾Â,ÁÂÁ¦U¦ì«e½ú,¥H¤U¬O½Æ²ßªº¤ß±oµù¸Ñ
Sub TEST()
Dim Brr, Crr, Z, i&, j%, V%, V7%
'¡ô«Å§iÅܼÆ:(Brr,Crr,Z)¬O³q¥Î«¬ÅܼÆ,i¬Oªø¾ã¼Æ,(j,V,V7)¬Oµu¾ã¼Æ
Set Z = CreateObject("Scripting.Dictionary")
'¡ô¥OZ³o³q¥Î«¬ÅܼƬO ¦r¨å
With Sheets("»¡©ú"): Brr = Range(.Cells(.UsedRange.Rows.Count, "A"), .[IV1].End(xlToLeft)): End With
'¡ôÃö©ó "»¡©ú"¤u§@ªíªºµ{§Ç:
'¥OBrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥H²Ä1¦C³Ì¥ªÃ䦳¤º®eÀx¦s®æ¨ì AÄæ¤w¨Ï¥Î¦C(³Ì¤j¦C¸¹)Àx¦s®æ,
'¥H³o½d³òÀx¦s®æȱa¤JBrr°}¦C¤¤
For j = 1 To UBound(Brr, 2)
'¡ô³]¶¶°j°é!¥OjÅܼƱq1 ¨ìBrr°}¦C³Ì¤j¯Á¤ÞÄ渹
If Left(Trim(Brr(1, j)), 6) <> "" Then Z(Left(Trim(Brr(1, j)), 6)) = j
'¡ô¦pªG²Ä1¦Cj°j°éÄæBrr°}¦CÈ¥h°£ÀY§ÀªÅ¥Õ¦r¤¸«á ¨ú¥ª°¼6¦r¤¸ªº·s¦r¦ê¤£¬OªÅ¦r¤¸!
'´N¥O¥H ²Ä1¦Cj°j°éÄæBrr°}¦CÈ¥h°£ÀY§ÀªÅ¥Õ¦r¤¸«á ¨ú¥ª°¼6¦r¤¸ªº·s¦r¦ê·íkey,
'jÅܼƷíitem¯Ç¤JZ¦r¨å¤¤
Next
Crr = Range([WIP!O1], [WIP!A65536].End(3))
'¡ô¥OCrr³o³q¥Î«¬ÅܼƬO ¤Gºû°}¦C,¥H[O1]Àx¦s®æ¨ì AÄæ³Ì«á¦³¤º®eÀx¦s®æ,
'¥H³o½d³òÀx¦s®æȱa¤JCrr°}¦C¤¤
For i = 2 To UBound(Crr)
'¡ô³]¶¶°j°é!¥OiÅܼƱq2 ¨ìBrr°}¦C³Ì¤j¯Á¤Þ¦C¸¹
V = Val(Crr(i, 15)): V7 = Val(Crr(i, 7)): Crr(i - 1, 1) = ""
'¡ô¥OV³oµu¾ã¼ÆÅܼƬO i°j°é¦C15ÄæCrr°}¦CÈÂà¤Æªº¼ÆÈ
'¡ô¥OV7³oµu¾ã¼ÆÅܼƬO i°j°é¦C7ÄæCrr°}¦CÈÂà¤Æªº¼ÆÈ
'¡ô¥O(i-1)°j°é¦C1ÄæCrr°}¦CȬOªÅ¦r¤¸
If Z.Exists(Left(Trim(Crr(i, 1)), 6)) <> Empty Then
'¡ô¦pªG¥H²Ä1¦Cj°j°éÄæCrr°}¦CÈ¥h°£ÀY§ÀªÅ¥Õ¦r¤¸«á ¨ú¥ª°¼6¦r¤¸ªº·s¦r¦ê(¥H¤UºÙ²£«~½s¸¹),
'Y¥H²£«~½s¸¹¬d¨ìZ¦r¨å¦³¦¹key!
Crr(i - 1, 1) = Round(Brr(V7 + 2, Z(Left(Trim(Crr(i, 1)), 6))) * V, 0)
'¡ô¥O(i-1)¦C1ÄæCrr°}¦CȬO (V7ÅܼÆ+2¦C,²£«~½s¸¹¬d¦r¨å¦^¶ÇitemÈÄæ)Brr°}¦CÈ,
'¦A¼¥HVÅܼƫá,¸ÓȤp¼Æ1¦ì¥|±Ë¤¤J¨ì¾ã¼Æ
ElseIf Right(Left(Trim(Crr(i, 1)), 7), 1) = "W" Then
'¡ô§_«h¦pªG¥H ²Ä1¦Cj°j°éÄæCrr°}¦CÈ¥h°£ÀY§ÀªÅ¥Õ¦r¤¸«á ¨ú²Ä7¦r¤¸¬O"W"!
Crr(i - 1, 1) = Round(Brr(V7 + 2, Z("W")) * V, 0)
'¡ô¥O(i-1)¦C1ÄæCrr°}¦CȬO (V7ÅܼÆ+2¦C,"W"¬d¦r¨å¦^¶ÇitemÈÄæ)Brr°}¦CÈ,
'¦A¼¥HVÅܼƫá,¸ÓȤp¼Æ1¦ì¥|±Ë¤¤J¨ì¾ã¼Æ
Else
Crr(i - 1, 1) = Round(Brr(V7 + 2, Z(Trim(Split(Crr(i, 2), "X")(0) & """"))) * V, 0)
'¡ô¥O(i-1)¦C1ÄæCrr°}¦CȬO (V7ÅܼÆ+2¦C,§å¸¹²Ä1³W®æ½X¬d¦r¨å¦^¶ÇitemÈÄæ)Brr°}¦CÈ,
'¦A¼¥HVÅܼƫá,¸ÓȤp¼Æ1¦ì¥|±Ë¤¤J¨ì¾ã¼Æ
'µù §å¸¹²Ä1³W®æ½X: i°j°é¦C²Ä2ÄæCrr°}¦CÈ,¥H"X"¤À³Î¦¨ªº¤@ºû°}¦Cªº²Ä0¯Á¤Þ¸¹°}¦CÈ ³s±µ "²Å¸¹
End If
Next
[WIP!D2].Resize(UBound(Crr) - 1, 1) = Crr
'¡ô¥O"WIP"¤u§@ªí[D2]¦V¤UÂX®iCrrÁa¦V³Ì¤j¯Á¤Þ¦C¸¹-1¦C,¦¹½d³òÀx¦s®æÈ¥HCrr°}¦Cȱa¤J
Set Z = Nothing: Erase Brr, Crr
'¡ô¥OÄÀ©ñÅܼÆ
End Sub |
|