【发布时间】:2022-09-25 03:48:15
【问题描述】:
我有一个工作表,我想在多个单元格更改事件和单元格上调用多个 subs。
在此工作表中,Range(\"K3\") 和 Range(\"K32\") 是公式单元格,我想为 Range(\"K3\") 调用 calculation() 和为 Range(\"K32\") 调用 calculation1()。
请指导。谢谢
Private Sub Worksheet_Calculate()
Static MyOldVal
Static MyOldVal1
If Range(\"K3\").Value <> MyOldVal Then
Call calculation
Else
If Cells(32, 11).Value <> MyOldVal1 Then Call calculation1
MyOldVal = Range(\"K3\").Value
MyOldVal1 = Range(\"K32\").Value
End If
End Sub
Private Sub calculation()
Cells(4, 10) = (Cells(11, 8) + Cells(16, 8) + Cells(28, 7) + (351 * Cells(25, 3))) / 0.9 / 0.7 * 1.2
Cells(5, 10) = (Cells(11, 8) + Cells(16, 8) + Cells(28, 7) + (351 * Cells(25, 3))) / 0.7 / 0.7 * 1.2
End Sub
Private Sub calculation1()
Cells(33, 10) = (Cells(40, 8) + Cells(45, 8) + Cells(57, 7) + (351 * Cells(54, 3))) / 0.9 / 0.7 * 1.2
Cells(34, 10) = (Cells(40, 8) + Cells(45, 8) + Cells(57, 7) + (351 * Cells(54, 3))) / 0.7 / 0.7 * 1.2
End Sub
-
worksheet_change事件?