返回列表 上一主題 發帖

[發問] 2儲存格中字串差異顯示

回復 1# free72921
  1. Sub zz()
  2. Dim a(1), b, c, d, s$, j%, ln%
  3. a(0) = Split([b3].Value, ",")
  4. a(1) = Split([c3].Value, ",")
  5. For i = 0 To UBound(a)
  6.     If i Then n = 0 Else n = 1
  7.     b = a(i)
  8.     For Each c In a(n)
  9.         b = Filter(b, c, 0)
  10.     Next
  11.     If UBound(b) >= 0 Then
  12.         s = Cells(3, i + 2).Value
  13.         For Each c In b
  14.             ln = Len(c)
  15.             j = Application.WorksheetFunction.Find(c, s)
  16.             Cells(3, i + 2).Characters(j, ln).Font.Color = vbRed
  17.         Next
  18.     End If
  19. Next
  20. End Sub
複製代碼

TOP

回復 6# free72921
  1. Sub zz()
  2. Dim a(1), b, c, d, s$, j%, ln%
  3. a(0) = Split([b3].Value, ",")
  4. a(1) = Split([c3].Value, ",")
  5. Set d = CreateObject("scripting.dictionary")
  6. For i = 0 To UBound(a)
  7.     If i Then n = 0 Else n = 1
  8.     For Each c In a(i)
  9.         d(c) = ""
  10.     Next
  11.     s = Cells(3, i + 2).Value
  12.     For Each c In a(n)
  13.         If Not d.exists(c) Then
  14.             ln = Len(c)
  15.             j = InStr(s, c)
  16.             Cells(3, i + 2).Characters(j, ln).Font.Color = vbRed
  17.         End If
  18.     Next
  19.     d.RemoveAll
  20. Next
  21. End Sub
複製代碼

TOP

        靜思自在 : 得理要饒人,理直要氣和。
返回列表 上一主題