[英]Excel Macro VBA: Double click to tick issue
how can I make the double click works ONLY when column 1,2,3 and 4 have values? 仅当第1,2,3和4列具有值时,如何才能使双击有效? I don't know where I should insert the code.. it's something like if column 1,2,3 and 4 have values then doubleclick.enable = TRUE else doubleclick.enable= FALSE.. 我不知道我应该在哪里插入代码..这就像第1,2,3和4列具有值,然后doubleclick.enable = TRUE否则doubleclick.enable = FALSE ..
Kindly need advice. 请咨询。 My code is as follows: 我的代码如下:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Select Case Target.Column
Case 6, 13
If Not Intersect(Target, Range("F2:F13, M2:M13")) Is Nothing Then Cancel = True
Target.Font.Name = "Times New Roman"
If Target = "" Then
Target = ChrW(&H2713)
Else
MsgBox "You cannot modify the cell."
End If
End Select
End Sub
I am asking just to clarify the issue. 我只是想澄清这个问题。 You only want to call doubleclick procedure if any cell in column 1 to 4 have value Or you want to check if corresponding row has value? 您只想在第1列至第4列中的任何单元格具有值时调用doubleclick过程,还是要检查相应的行是否具有值?
for option 1, you may use 对于选项1,您可以使用
If Application.CountA(Range("A1:D" & Rows.Count)) > 0 Then
'Your Code
End If
for second option 第二选择
If Application.CountA(Range("A" & target.Row & ":D" & target.Row)) > 0 Then
'Your Code
End If
I tested above codes but in case of any mistake, we can modify them 我测试了上面的代码,但是如果有任何错误,我们可以对其进行修改
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.