[英]Clear cell content based on another cell calculation
this is an Excel/VBA question: 这是一个Excel / VBA问题:
I have a cell A1 in sheet2 linked cell A1
in sheet1
(simply A1='sheet1'!A1
). 我在sheet2中有一个单元格
A1
在sheet1
链接了单元格A1
(简称A1='sheet1'!A1
)。 A1
in sheet1
is a data validation drop down menu. sheet1
中的A1
是数据验证下拉菜单。
I want to clear the content of A2
in sheet2
every time the content of A1
in sheet2 changes/is updated. 每当
sheet2
中A1
的内容更改/更新时,我想清除sheet2
中A2
的内容。 That is every time the value of A1
in sheet1
is changed using the drop down menu. 这是每次使用下拉菜单更改
sheet1
的A1
值。
I tried using a Worksheet_Change
event macro ( which I do not fully understand ) but it won't work with a cell that updates from a calculation. 我尝试使用
Worksheet_Change
事件宏( 我不完全理解 ),但它不适用于从计算更新的单元格。 It also doesn't work if triggered from a cell from another worksheet (I tried linking it to cell A1
on sheet1
in this case). 如果从另一个工作表中的单元格触发它也不起作用(在这种情况下我尝试将它链接到
sheet1
上的单元格A1
)。
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1")) Is Nothing Then Exit Sub
If Target.Count > 1 Then Exit Sub
Range("A2").ClearContents
End Sub
Can you think of a simple solution to clear the content of cell A2
in sheet2
when A1
in sheet2
updates? 你能想到一个简单的解决方案,以清除单元格的内容的
A2
在sheet2
,当A1
在sheet2
更新?
This works for me... 这对我有用......
This code goes in the Sheet code area of Sheet1 此代码位于Sheet1的Sheet代码区域中
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A1")) Is Nothing Then _
Sheets("Sheet2").Range("A2").ClearContents
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.