Worksheet_change代码用于不同纸张,并在一张纸上的数据
我在30张列表中列出了下拉列表,其中C列是下拉列表。根据所选标准,在D列中粘贴了另一个值。
我创建的代码仅适用于我的数据所在的表格。我想根据我的“数据”表在文件中的每个电子表格上执行代码。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Res As Variant
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("c6:c10")) Is Nothing Then
Res = Evaluate("INDEX(b2:b63,MATCH(" & Target.Address & ",A2:a63,0))").
If Not IsError(Res) Then Target.Offset(, 1) = Res
End If
End Sub
该代码与我的值一起在页面上起作用。用我的数据从表格中制作代码是什么,适用于文件上的其余表?
也许select.worksheet.data
在我的代码线之一或类似行之前?
I'm making a dropdown list on 30 sheets where column C is the dropdown list. Based on the selected criteria another value is pasted in column D.
I created code that only works for the sheet where my data is located. I want to execute my code on every spreadsheet in the file based on my ‘Data’ sheet.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Res As Variant
If Target.CountLarge > 1 Then Exit Sub
If Not Intersect(Target, Range("c6:c10")) Is Nothing Then
Res = Evaluate("INDEX(b2:b63,MATCH(" & Target.Address & ",A2:a63,0))").
If Not IsError(Res) Then Target.Offset(, 1) = Res
End If
End Sub
The code works on the page with my values. What do make the code from the sheet with my data apply to rest of the sheets on the file?
Maybe a select.worksheet.data
before one of my lines of code or something like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望上述代码在所有其他纸张中都可以使用(更改特定表的“ C6:C10”范围中的某些内容,以在“ D:D”列中带来
res
相应的工作表),请在thisWorkBook
代码模块中复制下一个代码事件(并从表中删除/评论现有的代码):但是,如果所有范围都有同步范围床单,需要复制与事件触发的表格中返回的
res
,请下一步改编您的代码:请,请在之后发送一些反馈测试看起来很方便的解决方案。
If you want the above code to work the same in all the other sheets (changing something in "C6:C10" range of a specific sheet to bring
Res
in column "D:D" of the respective sheet), please copy the next code event inThisWorkbook
code module (and delete/comment the existing one from the sheet):But if there are synchronized ranges in all sheets and need to copy the same returned
Res
from the sheet having the event triggered, please adapt your code in the next way:Please, send some feedback after testing the solution which looks convenient for you.