[英]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 FORMULA: Find if all the characters in a cell are in another cell even if in this another cell they are more characters. EXCEL公式:查找一个单元格中的所有字符是否都在另一个单元格中,即使在另一个单元格中它们是更多字符。 Example: A1 contains TRSA - B1 contains JHTHASUBR so return TRUE: all characters in A1 are in B1 even if they are not in order or B1 had more characters.
示例:A1包含TRSA-B1包含JHTHASUBR,因此返回TRUE:A1中的所有字符都位于B1中,即使它们不按顺序排列或B1包含更多字符。
I don't know if I can do that with a formula in excel? 我不知道我可以用Excel中的公式来做到这一点吗? Thank you.
谢谢。
Try the following U ser D efined F unction: 请尝试以下ü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
User Defined Functions (UDFs) are very easy to install and use: 用户定义函数(UDF)易于安装和使用:
If you save the workbook, the UDF will be saved with it. 如果您保存工作簿,则UDF将随之保存。 If you are using a version of Excel later then 2003, you must save the file as .xlsm rather than .xlsx
如果您在2003年以后使用Excel版本,则必须将文件另存为.xlsm而不是.xlsx
To remove the UDF: 删除UDF:
To use the UDF from Excel: 要从Excel使用UDF:
=IsItInThere(A1,B1) = IsItInThere(A1,B1)
To learn more about macros in general, see: 要总体上了解有关宏的更多信息,请参见:
http://www.mvps.org/dmcritchie/excel/getstarted.htm http://www.mvps.org/dmcritchie/excel/getstarted.htm
and 和
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
and for specifics on UDFs, see: 有关UDF的详细信息,请参见:
http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx http://www.cpearson.com/excel/WritingFunctionsInVBA.aspx
Macros must be enabled for this to work! 必须启用宏才能使其正常工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.