vba “Private Sub Worksheet_Change(ByVal Target As Range)” - 需要帮助:范围
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15337734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
“Private Sub Worksheet_Change(ByVal Target As Range)” -need help re: range
提问by user1941320
Private Sub Worksheet_Change(ByVal Target As Range)
Private Sub Worksheet_Change(ByVal Target As Range)
I was hoping to ‘borrow' this bit of code but was unsure what to place in for the range values. Why I wish to use it is for a data page for a workbook full of vlookups.
我希望“借用”这段代码,但不确定要为范围值放置什么。为什么我希望将它用于充满 vlookups 的工作簿的数据页。
On this page A through M is filled with data and occasionally is updated, by N through AB has formulas adding two of the data cells or merging information in them. RangeSource and Range Destination seem to be where I might need to adjust-HELP?
在这个页面上,A 到 M 填充了数据,偶尔会更新,N 到 AB 有公式添加两个数据单元格或合并其中的信息。RangeSource 和 Range Destination 似乎是我可能需要调整的地方-帮助?
Thank you in advance!
先感谢您!
回答by MattCrum
I think you are asking how to define the range of cells that should trigger this macro when changed? If so, use this:
我想您是在问如何定义更改时应触发此宏的单元格范围?如果是这样,请使用:
If Not Intersect(Target, Range("A:M")) Is Nothing Then
'Your Code Here
End If
That checks to see if the changed cell (Target) is in the defined range (Column A to Column M) and runs your code if it is.
这会检查更改的单元格(目标)是否在定义的范围内(A 列到 M 列),如果是,则运行您的代码。