請問我如何將庫存的活頁的資料,將它儲存到各活頁簿?
- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
回復 4# flask
資料應遵守資料庫建立規則要做分析就比較方便
以你目前的資料要分頁檢視程式碼如下- Sub ex()
- Dim a As Range
- Set dic = CreateObject("Scripting.Dictionary")
- Set d = CreateObject("Scripting.Dictionary")
- With Sheets("庫存")
- i = 1
- Do Until .Cells(1, i) = ""
- myday = .Cells(1, i).Value
- For Each a In .Range(.Cells(2, i), .Cells(.Rows.Count, i).End(xlUp))
- If IsEmpty(d(Val(a))) Then d(Val(a)) = a.Offset(, 1).Value
- ar = Array(a.Offset(, 3), a.Offset(, 4))
- If IsEmpty(dic(a & d(Val(a)))) Then
- dic(a & d(Val(a))) = ar
- Else
- dic(a & d(Val(a))) = Array(dic(a & d(Val(a)))(0) + ar(0), dic(a & d(Val(a)))(1) + ar(1))
- End If
- Next
- For Each ky In d.items
- With Sheets(ky)
- s = .Cells(2, .Columns.Count).End(xlToLeft).Column + 1
- .Cells(1, s) = myday: .Cells(2, s) = "買": .Cells(2, s + 1) = "賣"
- For Each a In .Range(.[A3], .Cells(.Rows.Count, 1).End(xlUp))
- .Cells(a.Row, s).Resize(, 2) = dic(a & ky)
- Next
- End With
- Next
- dic.RemoveAll: d.RemoveAll
- i = i + 5
- Loop
- End With
- End Sub
複製代碼 |
|
|
學海無涯_不恥下問
|
|
|
|
|
- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 142
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2026-7-16
                
|
.UsedRange.Columns.AutoFit
.Range(.Cells(2, s), .Cells(L, s)).FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
, Formula1:="10000"
.Range(.Cells(2, s), .Cells(L, s)).FormatConditions(1).Font.ColorIndex = 3
.Range(.Cells(2, s + 1), .Cells(L, s + 1)).FormatConditions.Add Type:=xlCellValue, Operator:=xlGreaterEqual _
, Formula1:="10000"
.Range(.Cells(2, s + 1), .Cells(L, s + 1)).FormatConditions(1).Font.ColorIndex = 5 |
|
|
學海無涯_不恥下問
|
|
|
|
|