Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA检查A是否适合B,但_Vba_Excel - Fatal编程技术网

VBA检查A是否适合B,但

VBA检查A是否适合B,但,vba,excel,Vba,Excel,我不知道如何解释,所以我只给你一个简单的例子 我有一些字符串,例如:123?56(?表示任何字符)。我想检查一根绳子是否能插进另一根 例如: 123456适合123-56 123B56也适用于123-56 你知道原则 现在,实际上有更长的字符串,更像是1234?9ZZ9???72?,我想做的是检查列中的其他字符串(我有所有数据)是否适合同一列中的任何其他字符串 理想情况下,它会返回给我每一组“相同的数字”,但这一部分我相信我能做到。我只是不知道如何接近?字符 大小很少超过4-10K行长。以下

我不知道如何解释,所以我只给你一个简单的例子

我有一些字符串,例如:
123?56
表示任何字符)。我想检查一根绳子是否能插进另一根

例如:

  • 123456
    适合
    123-56
  • 123B56
    也适用于
    123-56
你知道原则

现在,实际上有更长的字符串,更像是
1234?9ZZ9???72?
,我想做的是检查列中的其他字符串(我有所有数据)是否适合同一列中的任何其他字符串

理想情况下,它会返回给我每一组“相同的数字”,但这一部分我相信我能做到。我只是不知道如何接近
字符


大小很少超过4-10K行长。

以下是一些非常简单的代码,可以帮助您开始:

Sub CheckStrings()

    Dim string1 As String
    Dim string2 As String
    Dim string3 As String
    Dim string4 As String        

    string1 = "123?56"
    string2 = "123456"
    string3 = "123B56"
    string4 = "notamatch"

    If string2 Like string1 Then
        Cells(1, 1) = "Match"
    Else
        Cells(1, 1) = "No Match"
    End If

    If string3 Like string1 Then
        Cells(1, 2) = "Match"
    Else
        Cells(1, 2) = "No Match"
    End If

    If string4 Like string1 Then
        Cells(1, 3) = "Match"
    Else
        Cells(1, 3) = "No Match"
    End If

End Sub

当我运行该命令时,它会将“匹配”“不匹配”放在当前工作表的上角。希望这足以适应适当的解决方案?

如果“123456”类似于“123?56”,那么
?查看RegEx。它通常用于此应用程序。就像奥普拉特做的那样。谢谢大家!非常感谢。我怎么可能不认识这个接线员。Sub test()Dim i As Integer,j As Integer,count As Integer i=1:j=1:count=2 Dim lastrow As Integer lastrow=Cells(1000000,1)。End(xlUp)。如果单元格(i,1),i=1到lastrow的行数=2对于j=1到lastrow的行数=2。类似于单元格的值(j,1)。然后是单元格(i,count)。Value=j&“适合”&i count=count+1 End如果下一个j下一个i End Sub成功了。