简体   繁体   English

将值添加到所有工作表中列中的所有单元格

[英]Add a value to all cells in a column in all worksheets

I have found this macro on a website and it does exactly what I need it to do with the exception of I need to copy it down for all the rows in my spreadsheet and all sheets. 我已经在网站上找到了此宏,除了需要将其复制到电子表格和所有工作表中的所有行之外,它确实可以满足我的需要。 Can anyone help me with that? 有人可以帮我吗?

Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Range("A1"), Target) Is Nothing Then Exit Sub
    [B1] = [B1] + [A1]
End Sub

In ThisWorkbook , put your code in the Workbook_SheetChange event to make it change when any worksheet is changed. ThisWorkbook ,将您的代码放入Workbook_SheetChange事件中,以在更改任何工作表时对其进行更改。 For example: 例如:

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
'put your code here
End Sub

So for your above code, it would be this: 因此,对于您上面的代码,将是这样的:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM