- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
回復 1# janejacky
試試附件
出貨單歷史統計.rar (12.57 KB)
- 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
複製代碼 |
|