以下是c3单元格的事件代码,
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Range("c3") = Range("f2") - Application.Sum(Cells(5, 2), Cells(53, 2), Cells(101, 2), Cells(149, 2), Cells(197, 2), Cells(245, 2), Cells(293, 2), Cells(341, 2), Cells(389, 2), Cells(437, 2), Cells(485, 2), Cells(533, 2)) + Application.Sum(Cells(5, 8), Cells(53, 8), Cells(101, 8), Cells(149, 8), Cells(197, 8), Cells(245, 8), Cells(293, 8), Cells(341, 8), Cells(389, 8), Cells(437, 8), Cells(485, 8), Cells(533, 8)) + Range("l2") + Range("l1") - Application.Sum(Cells(11, 9), Cells(59, 9), Cells(107, 9), Cells(155, 9), Cells(203, 9), Cells(251, 9), Cells(299, 9), Cells(347, 9), Cells(395, 9), Cells(443, 9), Cells(491, 9), Cells(539, 9), Cells(7, 9), Cells(55, 9), Cells(103, 9), Cells(151, 9), Cells(199, 9), Cells(247, 9), Cells(295, 9), Cells(343, 9), Cells(391, 9), Cells(439, 9), Cells(487, 9), Cells(535, 9))
End Sub
f2的代码
Sub guanlian()
Dim i, m
For i = 4 To 13
For m = 4 To 13
For a = 1 To 10
Sheets("sheet" & a).Range("f2").Value = Sheets("首页登记").Range("s" & m).Value
i = i + 1
m = m + 1
Next
Next
Next
End Sub
现在的情况是,当在另一个工作表点击F2的代码填入第一个代码的工作表中时,C3的结果无法自动计算,只有打开工作表点任意单元格才能计算结果,如果实现自动计算呢?
|