简体   繁体   English

检查Excel工作表中单元格中几个字符串中是否存在长度字符串

[英]Check if there exists in an Excel sheet a string of length within several strings in cell

I would like to see if there exists a string of length 25 in a certain cell. 我想查看某个单元格中是否存在长度为25的字符串。 The problem is that the cell I want to check, contains several strings seperated by a space. 问题是我要检查的单元格包含多个由空格分隔的字符串。 Of these strings, I want to know if there is a string of length 25. 在这些字符串中,我想知道是否有长度为25的字符串。

If I use for example the LEN-function, I get the total length of the strings in the cell, while I want to see if there indeed exists a string of length 25 between all the strings in that cell. 例如,如果使用LEN函数,我将获得单元格中字符串的总长度,而我想查看该单元格中所有字符串之间是否确实存在长度为25的字符串。

You need to split the string into separate strings to use Len so use Split and loop through the array of strings. 您需要将字符串拆分为单独的字符串才能使用Len因此请使用Split并遍历字符串数组。 This is the code for a single cell check: 这是单个单元格检查的代码:

Dim WrdArray() As String
Dim TestLen As Integer

' Get the cell and split it into separate strings in an array
WrdArray() = Split(Range("A1"))

' Loop the strings array to find any that equal 25 characters long
For i = LBound(WrdArray) To UBound(WrdArray)
    TestLen = Len(WrdArray(i))
    If (TestLen = 25) Then
        MsgBox "found one"
    End If
Next i

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 检查字符串是否存在于两个字符串列表中(以逗号分隔) - check if string exists within two lists of strings (separated by commas) 如何检查Excel的列中是否存在字符串,其中单元格包含用逗号分隔的字符串 - How to check if a string exists in a column in excel where cells contain strings separated by comma 检查C#中字符串列表中是否存在字符串 - Check if string exists in list of strings in C# 检查输入字符串是否存在于 C 的字符串数组中 - Check if input string exists in array of strings in C 如何将字符串列表分成一行/单元格中的几行? - How to separate a list of strings into several lines within a row/cell? Excel VBA在字符串中搜索字符串数组 - Excel VBA to Search for an Array of Strings within a String 检查 Python 字符串是否是有效的 Excel 单元格 - Check if a Python string is a valid Excel cell 如何有效地计算字符串单元格数组的字符串长度 - How to compute effectively string length of cell array of strings 在一个单元格中写几个字符串 - Write several strings in one cell 在 VBA 中,如何检查字符串是否包含在单元格中找到的许多字符串中的任何一个? - In VBA, how to check if a string contains any of many strings found in a cell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM