1

我的代码有问题...看起来像这样

Worksheets("Daily Consump").Cells(67, OutputNumber).Value = (CDbl(Kiln.Cells(25, OutputNumber + 3).Value) - CDbl(Kiln.Cells(25, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(25, 4).Value)
Worksheets("Daily Consump").Cells(68, OutputNumber).Value = (CDbl(Kiln.Cells(26, OutputNumber + 3).Value) - CDbl(Kiln.Cells(26, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(26, 4).Value)
Worksheets("Daily Consump").Cells(69, OutputNumber).Value = (CDbl(Kiln.Cells(27, OutputNumber + 3).Value) - CDbl(Kiln.Cells(27, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(27, 4).Value)
Worksheets("Daily Consump").Cells(70, OutputNumber).Value = (CDbl(Kiln.Cells(28, OutputNumber + 3).Value) - CDbl(Kiln.Cells(28, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(28, 4).Value)
Worksheets("Daily Consump").Cells(71, OutputNumber).Value = (CDbl(Kiln.Cells(29, OutputNumber + 3).Value) - CDbl(Kiln.Cells(29, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(29, 4).Value)
Worksheets("Daily Consump").Cells(72, OutputNumber).Value = (CDbl(Kiln.Cells(30, OutputNumber + 3).Value) - CDbl(Kiln.Cells(30, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(30, 4).Value)
Worksheets("Daily Consump").Cells(73, OutputNumber).Value = (CDbl(Kiln.Cells(31, OutputNumber + 3).Value) - CDbl(Kiln.Cells(31, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(31, 4).Value)

我认为我的代码不好,你有什么建议用简单的代码制作它,也许使用循环,但我有任何失败:这里是我的试验

'For k = 25 To 31
'    For j = 67 To 73
'        Worksheets("Daily Consump").Cells(j, OutputNumber).Value = (CDbl(Kiln.Cells(k, OutputNumber + 3).Value) - CDbl(Kiln.Cells(k, OutputNumber + 2).Value)) * CDbl(Kiln.Cells(k, 4).Value)
'    Next j
'Next k

请告诉我该怎么做

4

2 回答 2

3
With Kiln
    For k = 25 To 31
        Worksheets("Daily Consump").Cells(k + 42, OutputNumber).value = (CDbl(.Cells(k, OutputNumber + 3).value) - CDbl(.Cells(k, OutputNumber + 2).value)) * CDbl(.Cells(k, 4).value)
    Next k
End With
于 2013-11-06T00:07:52.877 回答
0

我建议而不是 VBA 直接在 Excel 工作表中执行此操作。以下是如何制作公式的示例:

公式

结果单元格取列 Value A 和 Value B 之间的差异,并乘以列 Scale 上的数字。要输入公式,您需要CTRL-SHIFT-ENTER在选择结果单元格时按(如上所示)。结果如下所示:

结果

于 2013-11-06T14:36:29.060 回答