標題:
如何做跨頁出貨單歷史統計
[打印本頁]
作者:
janejacky
時間:
2011-5-8 11:37
標題:
如何做跨頁出貨單歷史統計
1.如何在出貨單歷史統計表中顯示出貨單資料
2.出貨單 統計完後當日還可繼續輸入第2筆不同客戶的資料 也會繼續顯示在出貨單歷史統計表中
要如何才能做出來ㄋ
作者:
GBKEE
時間:
2011-5-8 15:45
本帖最後由 GBKEE 於 2011-5-8 20:01 編輯
回復
1#
janejacky
更正:
試試看
Sub Ex()
Dim D(2) As Object, R As Variant, AR()
Set D(0) = CreateObject("Scripting.Dictionary")
Set D(1) = CreateObject("Scripting.Dictionary")
Set D(2) = CreateObject("Scripting.Dictionary")
With Sheets("出貨單")
For Each R In .Range(.[B12], .[G29]).Rows '出貨單內容範圍-> 的整列
If Application.CountA(R) = 6 Then '資料要齊全
AR = Array(.[G4].Text, .[G5], .[B5], R.Cells(1, 1), R.Cells(1, 2), R.Cells(1, 3), R.Cells(1, 5), R.Cells(1, 6))
D(1)(Join(AR, ",")) = AR
End If
Next
End With
With Sheets("出貨單歷史統計")
For Each R In .Range(.[A3], .Cells(Rows.Count, "H").End(xlUp)).Rows
If Application.CountA(R) = 8 Then D(0)(Join(Application.Transpose(Application.Transpose(R.Value)), ",")) = ""
D(2)(R.Cells(1, 1) & R.Cells(1, 2)) = D(2)(R.Cells(1, 1) & R.Cells(1, 2)) + R.Cells(1, 8)
Next
For Each R In D(1).KEYS
If D(0).EXISTS(R) = False Then
With .Cells(Rows.Count, "A").End(xlUp).Offset(1)
.Resize(, 8) = D(1)(R)
D(2)(.Cells(1) & .Cells(1, 2)) = D(2)(.Cells(1) & .Cells(1, 2)) + .Cells(1, 8)
End With
End If
Next
For Each R In .Range(.[A3], .Cells(Rows.Count, "A").End(xlUp))
If D(2).EXISTS(R & R(1, 2)) Then R(1, 9) = D(2)(R & R(1, 2))
Next
End With
Set D(0) = Nothing
Set D(1) = Nothing
Set R = Nothing
End Sub
複製代碼
作者:
janejacky
時間:
2011-5-8 17:39
我試過
但客戶名稱沒有到出貨統計表中ㄝ
作者:
Hsieh
時間:
2011-5-9 00:03
回復
1#
janejacky
試試附件
[attach]6067[/attach]
Sub inputdata() '儲存資料
Dim Rng As Range, Ay()
With Sheet1
Set Rng = .Range("A12:A29")
If Application.CountA(Rng) > 0 Then
For Each a In Rng.SpecialCells(xlCellTypeConstants)
ar = Array(.[G5].Value, .[G4].Value, .[B5].Value, a.Offset(, 1).Value, a.Offset(, 2).Value, a.Offset(, 3).Value, a.Offset(, 5).Value, a.Offset(, 6).Value)
ReDim Preserve Ay(s)
Ay(s) = ar
s = s + 1
Next
cnt = .[G32].Value
With Sheet2
Set a = .[A65536].End(xlUp).Offset(1)
a.Resize(s, 8) = Application.Transpose(Application.Transpose(Ay))
a.Offset(s - 1, 8) = cnt
End With
End If
End With
End Sub
Function PaperNo(Rng As Range, mydate As Date, k) '流水編號
Set d = CreateObject("Scripting.Dictionary")
mystr = Format(mydate, "yyyymmdd")
If Application.CountA(Rng) > 0 Then
For Each a In Rng.SpecialCells(xlCellTypeConstants)
If Left(a, 8) = mystr Then d(Val(a)) = ""
Next
End If
If d.Count > 0 Then
PaperNo = IIf(k = 1, Format(Application.Max(d.keys) + 1, "00000000000"), Format(Application.Max(d.keys), "00000000000"))
Else
PaperNo = mystr & "001"
End If
End Function
複製代碼
作者:
janejacky
時間:
2011-5-9 10:22
標題:
又發現不順
本帖最後由 janejacky 於 2011-5-10 15:55 編輯
真是謝謝
還要多學學
:$
又發現不順
出貨單的單號如何一樣同一天no.也都只有一個
單號會一樣 所以出現的出貨單歷史統計上總額也會依據上一張的總額
請問要如何怎麼處理?
還有忘記有一個稅額未加上去
請幫忙
謝謝
作者:
janejacky
時間:
2011-5-10 15:57
又發現問題了
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)