【发布时间】:2017-04-07 13:34:03
【问题描述】:
我有一个动态表,它是根据 Cells(4,"D") 和 Cells(6,"D") 的乘法创建的,它给出了总行数。列号是固定的,从 B 到 G 定义。第一行有数据是第 13 行。
我想写一个公式 deltaMassFormula,它在 B 列中引入以下内容:deltaMassFormula = D13 * (G13 - F13) 并自动填充,直到 countRows 等于总行数(乘法变量)
例如,如果乘法 = 4 那么
E13 = D13 * (G13 - F13)
E14 = D14 * (G14 - F14)
E15 = D15 * (G15 - F15)
E16 = D16 * (G16 - F16)
我的代码:
Dim StartCellM As Range
Dim lastRow As Long
Dim deltaMassFormula As Integer
Dim multiplication As Integer
multiplication = Cells(4, "D").Value * Cells(6, "D").Value
countRows = multiplication - 1
Set StartCellM = Cells(13, "E")
Set lastRow = Cells(13, "E") + countRows
deltaMassFormula = Cells(13, "D") * (Cells(13, "G") - Cells(13, "F"))
With ThisWorkbook.Sheets(1)
.Range("E13").Formula = deltaMassFormula
.Range("E13:E" & lastRow).FillDown
End With
有人可以帮助我吗?
【问题讨论】:
-
您发布的代码遇到了什么问题?
-
问题是代码没有填满E13下面的单元格。