对已经出现在线上的字符进行子串的最简单方法是什么?
是否可以通过功能执行此操作(表示没有VBA)?
更多信息:
如果我有像
这样的细胞*A* *B* *C* *D* *E* *F* | DATA | RESULT | 1 | A | B | C | | E | F | D 2 | C | | | | E | F | ABD
是否有可以提供此结果的功能:
fx("ABCEF", "ABCDEF")
返回D
fx("CF", "ABCDEF")
返回ABDE
答案 0 :(得分:1)
我怀疑simplest way
(或者至少不是最短的),但在没有VBA的情况下肯定是可能的:
=IF(ISERROR(MATCH("A",A2:F2,0)),"A","")&IF(ISERROR(MATCH("B",A2:F2,0)),"B","")&IF(ISERROR(MATCH("c",A2:F2,0)),"C","")&IF(ISERROR(MATCH("D",A2:F2,0)),"D","")&IF(ISERROR(MATCH("E",A2:F2,0)),"E","")&IF(ISERROR(MATCH("F",A2:F2,0)),"F","")
答案 1 :(得分:0)
试试这个小 UDF :
Public Function WhatsLeft(LittleString As String, BigString As String) As String
WhatsLeft = BigString
For i = 1 To Len(LittleString)
c = Mid(LittleString, i, 1)
WhatsLeft = Replace(WhatsLeft, c, "")
Next i
End Function
答案 2 :(得分:0)
作为数组的复杂公式可能能够做到这一点 - 但在编码站点上,我会保持简单并运行VBA UDF
Sub Test()
Debug.Print Updated("ABCEF", "ABCDEF")
Debug.Print Updated("CF", "ABCDEF")
End Sub
功能
Function Updated(strRep As String, strIn As String)
Dim objRegex As Object
Set objRegex = CreateObject("vbscript.regexp")
With objRegex
.Pattern = "[" & strRep & "]"
.Global = True
Updated = .Replace(strIn, vbNullString)
End With
End Function