標題:
算出日期比例,推出每季會花的錢
[打印本頁]
作者:
anny8888
時間:
2014-6-26 13:54
標題:
算出日期比例,推出每季會花的錢
各位大大,
要在4個日期中,計算出比例,再乘上工程款, 目前以公式代入, 若要轉換成程式,應如何做?
[attach]18565[/attach]
作者:
stillfish00
時間:
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
複製代碼
作者:
anny8888
時間:
2014-6-26 23:45
感謝大大迅速的解答.
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)