Excel - 显示缺失值
Excel - Displaying missing values
我正在寻求帮助,我正在尝试找出一种方法来从两个值中获取数据并在另一个框中显示不同之处。
例子
A B
1 The cat and dog |
2 The and dog | cat
3 cat and dog | the
4 the cat | and dog
有什么想法吗?
使用 VBA,您可以创建一个自定义函数,将被减数拆分为数组,将减数解析为字典,并循环遍历被减数数组以删除减数中的元素到 return 区别。希望对您有所帮助
使用 UDF:
Function LeftOver(Str1 As String, Str2 As String) As String
Dim spltstr
For Each spltstr In Split(Str2)
Str1 = Trim(Replace(Str1, spltstr, "", , , vbTextCompare))
Next spltstr
LeftOver = Replace(Str1, " ", " ")
End Function
然后你会把这个放在B1:
=LeftOver($A,A1)
试试这个用户定义的小函数:
Public Function WhatsMissing(s1 As String, s2 As String) As String
Dim IsInThere As Boolean
With Application.WorksheetFunction
ary1 = Split(.Trim(LCase(s1)), " ")
ary2 = Split(.Trim(LCase(s2)), " ")
End With
For Each a1 In ary1
IsInThere = False
For Each a2 In ary2
If a2 = a1 Then IsInThere = True
Next a2
If Not IsInThere Then WhatsMissing = WhatsMissing & " " & a1
Next a1
End Function
我正在寻求帮助,我正在尝试找出一种方法来从两个值中获取数据并在另一个框中显示不同之处。
例子
A B
1 The cat and dog |
2 The and dog | cat
3 cat and dog | the
4 the cat | and dog
有什么想法吗?
使用 VBA,您可以创建一个自定义函数,将被减数拆分为数组,将减数解析为字典,并循环遍历被减数数组以删除减数中的元素到 return 区别。希望对您有所帮助
使用 UDF:
Function LeftOver(Str1 As String, Str2 As String) As String
Dim spltstr
For Each spltstr In Split(Str2)
Str1 = Trim(Replace(Str1, spltstr, "", , , vbTextCompare))
Next spltstr
LeftOver = Replace(Str1, " ", " ")
End Function
然后你会把这个放在B1:
=LeftOver($A,A1)
试试这个用户定义的小函数:
Public Function WhatsMissing(s1 As String, s2 As String) As String
Dim IsInThere As Boolean
With Application.WorksheetFunction
ary1 = Split(.Trim(LCase(s1)), " ")
ary2 = Split(.Trim(LCase(s2)), " ")
End With
For Each a1 In ary1
IsInThere = False
For Each a2 In ary2
If a2 = a1 Then IsInThere = True
Next a2
If Not IsInThere Then WhatsMissing = WhatsMissing & " " & a1
Next a1
End Function