简体   繁体   English

如何在VBA的单元格范围内搜索excel,以获取不等于“短语”的字符串值

[英]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.

相关问题 如何在Java中的两个字符串之间搜索一系列值 - How do I search for a range of values in between two Strings in Java VBA 如何根据该范围内一个单元格的值有条件地格式化一系列单元格? - VBA How do I conditionally format a range of cells based on the value of one cell in that range? 如何在mongo文本搜索中将短语与php一起使用? - How do I use a phrase with php in a mongo text search? 如何在C#中的一段文本中搜索短语? - How do I search for a phrase in a piece of text in C#? 如何在字符串中搜索短语而不多次查找短语中的单词 - How do I search for a phrase in a string without looking for the word in the phrase multiple times 如何从excel中的单元格中仅提取5位字符串? - how do i extract only 5-digit strings from cells in excel? 如何使Excel VBA宏删除带有许多不同字符串作为标题的列? - How do I make an Excel VBA macro to delete columns with many different strings as headers? Excel VBA在字符串中搜索字符串数组 - Excel VBA to Search for an Array of Strings within a String 如何使Excel电子表格范围存储VBA变量? - How do you make an Excel spreadsheet range store a VBA variable? Excel:计算单元格范围内字符串中大于3的数字 - Excel: count numbers greater than 3 in strings in range of cells
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM