以下是我编写的程序,日期过滤库存以及仅对过滤后的数据进行基本计算。但我没有得到结果。相反,它显示0,仅显示在列的第二个单元格中。有人可以纠正它..? (见图)
Sub Filter_RPCALC()
'Calculation of Date Diff.
Range("N2").Formula = "=DAYS($A$590,D2)"
Range("N2").AutoFill Destination:=Range("N2:N585"), Type:=xlFillDefault
'Calculation of Rp
Dim Rp As Integer
Dim var1 As Integer
Dim var2 As Integer
Dim var3 As Integer
var1 = Range("M2:M585").Select
var2 = Range("02:0585").Select
var3 = Range("L2:L585").Select
Rp = var1 * var2 + var3
Range("P2:P585").Select
ActiveCell.FormulaR1C1 = Rp
'Filter the coils for Deliver Date
ActiveSheet.Range("$G$1:$G$585").AutoFilter Field:=1, Criteria1:="<" & CLng(Range("A590"))
End Sub
答案 0 :(得分:1)
为什么不使用类似下面的代码:
Dim LastRow As Long
LastRow = 585 ' using the value from your code , you could use a dynamic range here
Range("P2:P" & LastRow).Formula = "=M2*O2+L2"