- 帖子
- 1018
- 主題
- 15
- 精華
- 0
- 積分
- 1058
- 點名
- 0
- 作業系統
- win7 32bit
- 軟體版本
- Office 2016 64-bit
- 閱讀權限
- 50
- 性別
- 男
- 來自
- 桃園
- 註冊時間
- 2012-5-9
- 最後登錄
- 2022-9-28
|
2#
發表於 2014-6-26 15:55
| 只看該作者
回復 1# anny8888 - Sub Test()
- Dim rIndex As Long, cIndex As Long
- Dim s, e, p, qs, qe, d
-
- With Sheets("Ex1")
- For rIndex = 6 To .Cells(.Rows.Count, "A").End(xlUp).Row
- s = .Cells(rIndex, 1).Value
- e = .Cells(rIndex, 2).Value
- p = .Cells(rIndex, 3).Value
- For cIndex = 4 To .Cells(1, .Columns.Count).End(xlToLeft).Column
- qs = .Cells(1, cIndex)
- qe = .Cells(2, cIndex)
- d = Application.Min(e, qe) - Application.Max(s, qs) + 1
- .Cells(rIndex, cIndex).Value = IIf(d > 0, p * d / (e - s + 1), "")
- Next
- Next
- End With
- End Sub
複製代碼 |
|