更改匹配代码以在最初编写的不同形状数据上运行

时间:2015-12-29 17:15:53

标签: excel-vba fuzzy-comparison vba excel

我不记得我在哪里找到了这段代码,因此我无法向其作者提供正确的归属,但fuzzy matches两列字符串

我想更改代码,以便LookWith列处于coluwn B而不是列E我已经尝试了一段时间来执行此操作但是无法在不打破代码

由于

代码编写的数据的原始形状 Original shape of data

Sub FuzzyMatch()
Dim F As Range, n As Long, c As Long, k As Long 'Taisir
Dim FN As String, SN As String, Z, s As Long, r As Long

For r = 2 To Range("A" & Rows.Count).End(xlUp).Row
SN = Replace(Cells(r, 1), ",", ""): Z = Split(SN): SN = Z(0)
Set F = Range("E:E").Find(SN)
If Not F Is Nothing Then
  s = F.Row: FN = Cells(s, 5): c = 1
  For n = 1 To UBound(Z): SN = Z(n)
   If Len(SN) < 3 Then GoTo GetNextn
     Set F = Rows(s).Find(SN)
      If Not F Is Nothing Then
       c = c + 1
         If c >= UBound(Z) - 1 Then
           If Cells(s, 6) <> "" Then k = k + 1 Else k = 6
             Cells(s, k).Resize(1, 2).Value = Cells(r, 1).Resize(1, 2).Value: End If
         GoTo GetNext: End If
GetNextn: Next n: End If
GetNext: Next r

End Sub

0 个答案:

没有答案