简体   繁体   English

检测不同纸张上的单元格更改事件

[英]Detecting cell change events on different sheets

I have a workbook which has two sheets. 我有一张有两张纸的工作簿。 In either sheet, cell A1 calls a function and asynchronously the data is returned X seconds later to the Excel cache. 在任一工作表中,单元格A1调用一个函数,并且异步地将数据在X秒后返回到Excel缓存。 Then, once this data is loaded, I have an array function starting A2 which pastes the data into the sheet. 然后,一旦加载了这个数据,我就有一个从A2开始的数组函数,它将数据粘贴到工作表中。

I would like to automate this. 我想自动化这个。 I have written basic Workbook_SheetChange functions, but could someone please show me an example where I can check the sheet name, that caused the change? 我已经编写了基本的Workbook_SheetChange函数,但有人可以给我看一个示例,我可以检查工作表名称,导致更改吗?

Not sure if i understand what you need exactly, but you can catch the SheetChange event on at the Workbook level as well. 不确定我是否完全了解您的需求,但您也可以在Workbook级别上捕获SheetChange事件。 Sample: 样品:

Option Explicit

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
  If (TypeOf Sh Is Worksheet) Then
    Debug.Print "SheetChange occured in sheet [" & Sh.Name & "] in range [" & Target.Address & "]"
  End If
End Sub

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

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