[英]How do I search through a Range of cells in VBA for excel for values that are a strings not equal to “phrase”
I've been asked to program a simple enough task in VBA, I usually work with Java and have never even looked at VBA. 我被要求在VBA中编写一个足够简单的任务,我通常使用Java,甚至从未研究过VBA。 I'm not really getting what I want when i google it so I thought i'd ask here.
我用谷歌搜索时并没有真正得到想要的东西,所以我想在这里问。
How do I search through a Range of cells in VBA for excel for values that are a strings not equal to "phrase" 如何在VBA的单元格范围中搜索excel,以获取不等于“短语”的字符串值
Apologies for what seems like such a simple question but this isnt my area, any feedback is much appreciated 对于看起来如此简单的问题,我们深表歉意,但这不是我的专长,非常感谢您提供任何反馈意见
Martin 马丁
Please see below. 请看下面。 You can change your range accordingly
您可以相应地更改范围
Sub searchfor()
Dim rng As Range
Set rng = Range("A1:B100") ' Identify your range
For Each c In rng.Cells
If c.Value <> "" And c.Value <> "phrase" Then '<--- Will search if the cell is not empty and not equal to phrase. If you want to check empty cells too remove c.value <> ""
MsgBox (c.Address & "Not Equal") '<---- Your code goes here
End If
Next c
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.