excel - 将数字与随机字母和数字的文本字符串完全匹配
问题描述
我在 col.B 中的 Sheet2 中只有从 B2 开始的数字:81、102(在 B3 中)、104(在 B4 中)等,并且在 col.A 中的 Sheet1 中以 A2 开头,混合文本与没有逻辑位置文本的数字比如:abc813bnm 12mn(A2),fgh 81lkj 45ol(A3),ert1042hji(A4),等等。我需要从 col.A/Sheet1 中的 col.B/Sheet2 中搜索每个数字,并在 col.Q 的同一行中写入一个完全匹配的数字。第一个81号的精确匹配在A3(fgh 81lkj 45ol)中,但不在A2(abc813bnm 12mn)中,它在813字符串内。在我的代码 81(并且不仅)中,它是“找到”的,并且在具有 81 的单元格中和具有 813 的单元格中,我不希望这样:
子搜索LCL()
Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False
Application.DisplayStatusBar = False
Application.EnableEvents = False
Dim LCL1 As String
Dim LCL2 As String
'Dim answer As String
Dim c As Range
Dim counter As Long
Dim totalLCL1 As Long
Dim totalLCL2 As Long
counter = 2
'Sheets("MailElibLCL").Select 'Sheet2
'Sheets("lucrari 2017").Select 'Sheet1
totalLCL2 = Worksheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
totalLCL1 = Worksheets("Sheet2").Range("B" & Rows.Count).End(xlUp).Row
'totalLCL2 = N
'totalLCL1 = N3
For I = 2 To totalLCL2
'answer = Worksheets("hedis1").Range("h" & counter).Value
LCL2 = Worksheets("Sheet1").Range("A" & counter).Value
'LCL2 = "=MID(Worksheets.Sheet1.Range(""A"" & counter),SEARCH(LCL1,Worksheets.Sheet1.Range(""A"" & counter)),LEN(LCL1))"
k = "Q" & counter
For j = 2 To totalLCL1
LCL1 = Worksheets("Sheet2").Range("B" & j).Value
If InStr(1, LCL2, LCL1, vbTextCompare) > 0 Then
Debug.Print LCL1
'If LCL1 = LCL2 Then
'If answer = "Yes" Then
For Each c In Worksheets("Sheet1").Range(k)
'c.Value = Mid(LCL2, Search(LCL1, LCL2), Len(LCL1))
'c.Formula = "=MID(LCL2,INSTR(LCL1,LCL2),LEN(LCL1))"
'c.EntireRow.Interior.Color = 6 ' Change the number to match the desired color.
c.Value = LCL1 '& vbLf & Date 'Now (si ora minute secunde)
'c.Interior.Color = 5296210 ' Change the number to match the desired color.
Next c
'End If
'End If
End If
Next j
counter = counter + 1
Next I
'Else '调用 ScrieMailElib 'End If
错误转到 0
Application.EnableEvents = True
Application.DisplayStatusBar = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
结束子
谢谢你。
解决方案
我认为您可以只使用一个公式,例如,此示例在 abc30ded435wdfq345 中检查 30
=IF(ISERROR(SEARCH(30,J16,1)),"No Match","Match")
不确定我是否完全理解您的问题。
推荐阅读
- c# - C# iText7文本坐标提取题
- javascript - 如何在 Next.js 中正确使用 Mongoose 模型?
- r - 当样本量超过 5000 时测试分布
- python - 将列类型从对象转换为日期格式 - python
- ruby-on-rails - Omniauth-Saml with Devise - 映射和使用属性
- javascript - 如何提高 PixiJS 画布的质量?
- python - 数据帧中系列的多级过滤和频率计数
- java - 为什么 Glassfish 5.1 容器不调用单例中注入的 CDI 拦截器
- swift - 如何修复错误:线程 1:致命错误:索引超出范围”?
- laravel - Laravel Jensseger Mongodb 属于ToMany 附加字段