- ©«¤l
- 406
- ¥DÃD
- 8
- ºëµØ
- 0
- ¿n¤À
- 453
- ÂI¦W
- 0
- §@·~¨t²Î
- WINDOWS 7
- ³nÅ骩¥»
- 2007
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥xÆW
- µù¥U®É¶¡
- 2015-2-7
- ³Ì«áµn¿ý
- 2021-7-31
|
¥»©«³Ì«á¥Ñ n7822123 ©ó 2018-11-24 18:34 ½s¿è
¦^´_ 3# n7822123
«ö¤U²Îp«ö¶s§Y¥i¡A§Úªº¹q¸£³t«×´X¬íÄÁ§Y¥i§¹¦¨
Sub ²Îp()
Dim Arr, °Ïº¦C, °Ï¦C¼Æ, d As Object
Dim «¬¸¹$, ¤é´Á$, ©±¦W$, Ãþ«¬$, Str$, °Ïº¦C¦ê$, °Ï¦C¼Æ¦ê$
Dim ¤é´Á°_&, ¤é´Á²×&, i%, R%, C%, Rn%, Cn%, °Ï¼Æ%
Application.ScreenUpdating = False
Set d = CreateObject("scripting.dictionary")
¤é´Á°_ = [²Îp!D1]: ¤é´Á²× = [²Îp!F1]
Ãþ«¬ = [²Îp!H1]
'====¿é¤J¸ê®Æ¨ì¦r¨å¡A¦r¨åªºKey¨Ì©±¦W¡B«¬¸¹°µ°Ï¤À====
'==========¨ÌÃþ«¬°µ¿z¿ï¡A¨Ã¨Ì¤é´Á¥[Á`==========
Sheets("¼Æ¾Ú¨Ó·½").Activate
Arr = Range([C4], Cells(Rows.Count, 394).End(xlUp))
Rn = UBound(Arr): Cn = UBound(Arr, 2) - 1
For R = 3 To Rn: For C = 2 To Cn
©±¦W = Arr(1, C): «¬¸¹ = Arr(R, 1)
¤é´Á = Arr(R, 392): Str = ©±¦W & "," & «¬¸¹
If Arr(2, C) = Ãþ«¬ And ¤é´Á >= ¤é´Á°_ And ¤é´Á <= ¤é´Á²× Then d(Str) = d(Str) + Arr(R, C)
Next: Next
'============¿é¥X¦r¨å¸ê®Æ¨ì²Îp¤u§@ªí============
Sheets("²Îp").Activate
Rn = Cells(Rows.Count, 2).End(xlUp).Row
For R = 1 To Rn '¥ý§PÂ_¥X¦U¤p°Ï(¦X¨ÖÀx¦s®æ)ªºº¦C»P¦C¼Æ
If Cells(R, 2) Like "*°Ï" Then
°Ïº¦C¦ê = °Ïº¦C¦ê & "," & R
°Ï¦C¼Æ¦ê = °Ï¦C¼Æ¦ê & "," & Cells(R, 2).MergeArea.Rows.Count - 1 '¦©±¼¤pp¦C
°Ï¼Æ = °Ï¼Æ + 1
End If
Next R
°Ïº¦C = Split(°Ïº¦C¦ê, ","): °Ï¦C¼Æ = Split(°Ï¦C¼Æ¦ê, ",") '©î¦¨°}¦C
Cn = [E4].End(2).Column - 4 '²Îpªín¿é¤J¸ê®ÆªºÄæ¼Æ
For i = 1 To °Ï¼Æ '±q¦r¨å¤ñ¹ïkey¨Ã¿é¥X¸ê®Æ¨ì¬ÛÀ³Äæ¦C
Arr = Cells(°Ïº¦C(i), 5).Resize(°Ï¦C¼Æ(i), Cn)
For C = 1 To Cn: For R = 1 To °Ï¦C¼Æ(i)
©±¦W = Cells(R + 4, 4): «¬¸¹ = Cells(4, C + 4)
Arr(R, C) = d(©±¦W & "," & «¬¸¹)
Next R: Next C
Cells(°Ïº¦C(i), 5).Resize(°Ï¦C¼Æ(i), Cn) = Arr
Cells(Val(°Ïº¦C(i)) + Val(°Ï¦C¼Æ(i)), 5).Resize(, Cn) = "=sum(R[-" & °Ï¦C¼Æ(i) & "]C:R[-1]C)" '¤pp¦C¤½¦¡(Sum.....)
Next i
End Sub
test-1124.rar (914.48 KB)
|
|