问题描述
当 K4 中的某些内容发生更改时,以下 VBA 代码非常适合清除单元格 L4 的内容。
If Not Intersect(Target,Range("K4")) Is nothing Then
Range("L4").ClearContents
End If
但是现在,让我们说,我有一个名为“my_tbl”的动态扩展的 excel 表,我该如何更改上面的代码以使其适用于动态扩展的 excel 表“my_tbl”。
解决方法
谢谢指点。以下是对我有用的方法:
For i = 1 To Range("Table1").Rows.Count
If Not Intersect(Target,Range("Table1[loc1_type]")(i)) Is Nothing Then
Range("Table1[loc1]")(i).ClearContents
End If
Next i