[英]Excel FORMULA: Find if all the characters in a cell are in another cell even if in this another cell they are more characters
EXCEL公式:查找一個單元格中的所有字符是否都在另一個單元格中,即使在另一個單元格中它們是更多字符。 示例:A1包含TRSA-B1包含JHTHASUBR,因此返回TRUE:A1中的所有字符都位於B1中,即使它們不按順序排列或B1包含更多字符。
我不知道我可以用Excel中的公式來做到這一點嗎? 謝謝。
請嘗試以下üSER d efined˚F油膏:
Public Function IsItInThere(r1 As Range, r2 As Range) As Boolean
Dim v1 As String, v2 As String, CH As String
Dim i As Long
IsItInThere = False
v1 = r1.Text
v2 = r2.Text
For i = 1 To Len(v1)
CH = Mid(v1, i, 1)
If InStr(v2, CH) = 0 Then
Exit Function
End If
Next i
IsItInThere = True
End Function
用戶定義函數(UDF)易於安裝和使用:
如果您保存工作簿,則UDF將隨之保存。 如果您在2003年以后使用Excel版本,則必須將文件另存為.xlsm而不是.xlsx
刪除UDF:
要從Excel使用UDF:
= IsItInThere(A1,B1)
要總體上了解有關宏的更多信息,請參見:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
和
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
有關UDF的詳細信息,請參見:
http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx
必須啟用宏才能使其正常工作!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.