- 帖子
- 4901
- 主題
- 44
- 精華
- 24
- 積分
- 4916
- 點名
- 121
- 作業系統
- Windows 7
- 軟體版本
- Office 20xx
- 閱讀權限
- 150
- 性別
- 男
- 來自
- 台北
- 註冊時間
- 2010-4-30
- 最後登錄
- 2025-5-19
               
|
5#
發表於 2012-9-5 16:24
| 只看該作者
本帖最後由 Hsieh 於 2012-9-5 16:26 編輯
回復 4# jimmy510
不知道是不是這個意思
彙整資料又有計算欄位可能用VBA比較單純- Sub ex()
- Dim ar()
- ReDim Preserve ar(s)
- ar(s) = Array("尺寸", "日期", "數量", "單價", "總額", "備註")
- s = 1
- st = InputBox("輸入起始日期", , Format(DateAdd("M", -12, Date), "e/m/d"))
- st1 = InputBox("輸入起始日期", , Format(Date, "e/m/d"))
- For Each sh In Sheets
- With sh
- If .Name Like "刀模*" Then
- For Each a In .Range(.[A3], .Cells(.Rows.Count, 1).End(xlUp))
- If CDate(a) >= CDate(st) And CDate(a) <= CDate(st1) Then
- ReDim Preserve ar(s)
- ar(s) = Array(.[A1].Value, a.Value, a.Offset(, 1).Value, a.Offset(, 2).Value, a.Offset(, 1).Value * a.Offset(, 2).Value, a.Offset(, 3).Value)
- s = s + 1
- End If
- Next
- End If
- End With
- Next
- If s > 1 Then
- With Worksheets.Add(after:=Sheets(Sheets.Count))
- .[A1].Resize(s, 6) = Application.Transpose(Application.Transpose(ar))
- End With
- Else
- MsgBox "沒有符合資料"
- End If
- End Sub
複製代碼 |
|