你的表主要是公式计算,取消在表格里面设置,加个“核算”按钮自动计算好了:
Private Sub CommandButton6_Click()
'自动计算
Dim i, j, k, a, b, c, d, e, z
For i = 6 To 13 '[B65536].End(xlUp).Row
If Cells(i, 2) <> "" Then
a = Split(Cells(i, 2), "*")(0)
b = Split(Cells(i, 2), "*")(1)
c = Split(Cells(i, 2), "*")(2)
d = Cells(i, 15)
If Cells(i, 3) <> "" Then
z = Cells(i, 3)
Else
z = 1
End If
Cells(i, 4) = z * a * b * c * d / 1000000
Cells(i, 5) = z * b * c / 1000000
Cells(i, 7) = Cells(i, 4) * Cells(i, 6)
Cells(i, 10) = Cells(i, 8) * Cells(i, 9)
End If
Next
End Sub
对于不同公司的表格格式的设置,主要将代码里面所有涉及到的变量、单元格都对应起来,所需的数据对应提取就行了。
|