Excel匹配字母

idfiyjo8  于 12个月前  发布在  其他
关注(0)|答案(4)|浏览(148)

我想在Excel中找到一种方法,

ABC-DEFDEF-ABC相同

有人知道怎么做吗?

kqlmhetl

kqlmhetl1#


的数据
公式是这样的

=IF(AND(RIGHT(A8,3)=LEFT(A9,3),LEFT(A8,3)=RIGHT(A9,3)),TRUE,FALSE)

字符串

aemubtdh

aemubtdh2#

有时,但只是有时,(特色 manchmal aber努尔manchmal)你可能会幸运地发布这样的问题得到回答:

Option Explicit

Public Sub TestMe()
    
    Debug.Print CompareMe("ABC-DEF", "DEF-ABC")
    Debug.Print CompareMe("ABC-DEF", "DEF-AAC")
    
End Sub

Public Function CompareMe(strCompareA As String, strCompareB As String, Optional strDelim = "-")

    Dim arrA    As Variant
    Dim arrB    As Variant
    
    arrA = Split(strCompareA, strDelim)
    arrB = Split(strCompareB, strDelim)
    
    CompareMe = (arrA(0) = arrB(1) And arrA(1) = arrB(0))

End Function

字符串
检查TestMe sub,它会在控制台中打印结果。
此外,this is an interview algorithm question, asked by Google。这是一个通用的工作答案- * 反转整个字符串,然后按单词拆分,并反转每个单词 *。这是如何使用this is an interview algorithm question, asked by Google

Option Explicit

Public Sub TestMe()

    Debug.Print strReverseOrder("ABC-DEF-GHI")
    Debug.Print strReverseOrder("ABC-DEF") = "DEF-ABC"
    
End Sub

Public Function strReverseOrder(strToReverse As String, Optional strDelim = "-")

    Dim strWorking          As String
    Dim arrWorking()        As String
    Dim lngCounter          As Long
    Dim strAnswer           As String
    
    strWorking = StrReverse(strToReverse)
    arrWorking = Split(strWorking, strDelim)
    
    For lngCounter = LBound(arrWorking) To UBound(arrWorking)
        strAnswer = IIf(lngCounter = LBound(arrWorking), vbNullString, strAnswer & strDelim) & StrReverse(arrWorking(lngCounter))
    Next lngCounter

    strReverseOrder = strAnswer

End Function

uhry853o

uhry853o3#

以下为我工作:

=IF(D2>H2,CONCATENATE(D2,"-",H2),CONCATENATE(H2,"-",D2))

字符串

hec6srdp

hec6srdp4#

假设这是A1,将其放入B1=IF(A1="ABC-DEF","DEF-ABC",A1)中。向下拖动以填充。

相关问题