我在一个网站上找到了这个宏,除了我需要将其复制到我的电子表格和所有表格中的所有行之外,它完全符合我的需要。任何人都可以帮助我吗?
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Range("A1"), Target) Is Nothing Then Exit Sub
[B1] = [B1] + [A1]
End Sub
答案 0 :(得分:0)
在ThisWorkbook
中,将代码放入Workbook_SheetChange
事件中,以便在更改任何工作表时进行更改。例如:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
'put your code here
End Sub
所以对于上面的代码,就是这样:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Intersect(Range("A1"), Target) Is Nothing Then Exit Sub
[B1] = [B1] + [A1]
End Sub