将val目标更改为范围以忽略空白和0值单元格 [英] Change by val target as range to ignore blank and 0 value cells
本文介绍了将val目标更改为范围以忽略空白和0值单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每个c在Target.Cells $ b中$ b **如果c.Value<>空或c.Value = 0然后
结束如果**
如果c.Column = 11然后
c.Offset(0,-1).Value = Now()
结束如果
下一步c
结束Sub
我有上面的代码工作得很好,除了我试图添加粗体代码来忽略任何空白单元格(也可以选择忽略0值单元格,但不是必需的)。
谢谢
解决方案
如果c.Value!=
应该为空白单元格工作。
至少在这里。
对于忽略值0,如果c.Value>不能将if子句更改为 0
?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Range
For Each c In Target.Cells
**If c.Value <> Empty Or c.Value = 0 Then
End If**
If c.Column = 11 Then
c.Offset(0, -1).Value = Now()
End If
Next c
End Sub
I have the above code working well except I am trying to add the bolded code to ignore any blank cells (could also be the option of ignoring 0 value cells, but not necessary).
Thanks
解决方案
If c.Value != ""
should work for blank cells.
At least it worked here.
As for ignoring the value 0, couldn't you just change the if clause to if c.Value > 0
?
这篇关于将val目标更改为范围以忽略空白和0值单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文