[英]Can we run vba sub by clicking a cell which has a formula?
Is it possible to run the VBA Sub by clicking a cell which has a formula in it. 是否可以通过单击其中包含公式的单元格来运行VBA Sub。
I know its possible to run on a cell which doesn't have a formula to determine its value. 我知道可以在没有公式确定其值的单元格上运行。
How to go about it? 怎么做呢?
Kindly share your thoughts. 请分享您的想法。
Thanks in advance. 提前致谢。
Just use the selection change event and test the .HasFormula
property: 只需使用选择更改事件并测试
.HasFormula
属性即可:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count = 1 And Target.HasFormula Then
'// your code here
End If
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.