回復 10#olisun 07# 程式碼中
Set Rng = .[j15:l26] 改成 Set Rng = .[Q15:Q26]
刪掉 11. AD = AD - Evaluate("SUMIF(" & 工作表17.[A:A].Address(, , , 1) & ",""<" & d - (W - 1) & """, " & 工作表17.Columns(1 + (i * 12) + ii).Address(, , , 1) & ")")
就可以作者: olisun 時間: 2010-8-30 17:17
本帖最後由 Hsieh 於 2010-8-30 22:19 編輯
可能有點誤會,因為原來的P15:P26是派報,Q15:Q26是夾報
在"派夾報宣傳車"中日期是A:A 派報是B:M 夾報是N:Y
所以我下列式子在P15:P26是對的,可是Q15:Q26我就不會設了
Private Sub CommandButton2_Click()
With Sheets("日報表")
Set c = Sheets("派夾報宣傳車").Range("a:a").Find(.[E2], lookat:=xlWhole)
Arr = Sheets("派夾報宣傳車").[a3].Resize(c.Row - 2, 13)
For i = 15 To 26
Sheets("日報表").Range("p" & i).Value = Application.Sum(Application.Index(Arr, 0, i - 13))
Next i
End With
End Sub作者: Hsieh 時間: 2010-8-30 22:48
If Year(dt) = Year(Sheets("日報表").[E2]) And Application.WeekNum(dt, 2) = Application.WeekNum(Sheets("日報表").[E2], 2) Then
For Each a In .Range(.[B2], .[B2].End(xlToRight))
w = a.Offset(-1, 0).MergeArea.Cells(1, 1)
d(w & a) = d(w & a) + .Cells(r, a.Column).Value
Next
End If
r = r + 1
dt = .Cells(r, 1)
Loop
End With
Next
With Sheets("日報表")
For Each a In .[B15:B26]
at = a
For Each b In .[P14:U14]
If b.Column > 18 Then at = ""
.Cells(a.Row, b.Column) = d(b & at)
Next
Next
End With
複製代碼
作者: olisun 時間: 2010-8-30 23:40
因為我套在我的式子裡,而我式子中有Dim d As Date這一句,所以我改成
Set g = CreateObject("Scripting.Dictionary")
但是出現型態不符合作者: olisun 時間: 2010-8-30 23:46
上一個問題是我dim有加了一句dim g as range,改了之後又出現另一個
Set g = CreateObject("Scripting.Dictionary")
For Each sh In Sheets(Array("派夾報宣傳車", "NP、CF"))
With sh
R = 3
gt = .Cells(R, 1)
Do Until gt > Sheets("日報表").[E2]
For Each a In .Range(.[B2], .[B2].End(xlToRight))
W = a.Offset(-1, 0).MergeArea.Cells(1, 1) ----------- 型態不符
g(W & a) = g(W & a) + .Cells(R, a.Column).Value
Next
R = R + 1
dt = .Cells(R, 1)
Loop
End With
Next
With Sheets("日報表")
For Each a In .[B15:B26]
at = a
For Each b In .[P14:U14]
If b.Column > 18 Then at = ""
.Cells(a.Row, b.Column) = g(b & at)
Next
Next
End With作者: olisun 時間: 2010-8-31 00:24