excel 只连接大写字母?

q0qdq0h2  于 2023-02-17  发布在  其他
关注(0)|答案(3)|浏览(275)

在Excel(2021)中,我有一个包含以下单词的单元格:

all Upper case LeTters supposed to be In result

我需要结果:

ULTI

如果没有VBA(即纯Excel函数),我怎么能做到这一点?
我搜索了一下,但是“大写”和“concatenate”函数都会导致concatenate并使大写,而不是相反:连接IF大写。
虽然我找到了一个,但它看起来相当丑陋,我认为(希望)有更好的解决方案:

=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE
(SUBSTITUTE(SUBSTITUTE(txt,"a",""),"b",""),"c",""),"d",""),"e",""),
"f",""),"g",""),"h",""),"i",""),"j",""),"k",""),"l",""),"m",""),"n",""),"o",""),
"p",""),"q",""),"r",""),"s",""),"t",""),"u",""),"v",""),"w",""),"x",""),"y",""),
"z","")," ","")
x4shl7ld

x4shl7ld1#

在ms365中,尝试:

B1 ‡中的公式:

=CONCAT(TEXTSPLIT(A1,TEXTSPLIT(A1,CHAR(ROW(65:90)),,1)))

‡如果除了大写字母之外没有一个字符出现,这将抛出错误。在这种情况下,只需在内部TEXTSPLIT()中添加一个大写字母之外的尾随字符,例如:=CONCAT(TEXTSPLIT(A1,TEXTSPLIT(A1&"a",CHAR(ROW(65:90)),,1)))
对于Excel 2021:

=LET(x,MID(A1,SEQUENCE(LEN(A1)),1),CONCAT(IF((CODE(x)>64)*(CODE(x)<91),x,"")))
1zmg4dgp

1zmg4dgp2#

MS 365的另一个;

=LET(
Input,A1,
LetterArray,MID(Input,SEQUENCE(LEN(Input)),1),
Filtered, FILTER(LetterArray, EXACT(LetterArray, UPPER(LetterArray))*(LetterArray<>" ")*(ISERR(NUMBERVALUE(LetterArray))), "No Uppercase letters found"),
TEXTJOIN("", TRUE, Filtered)
)

其中A1包含文本输入。

dw1jzc5e

dw1jzc5e3#

我知道你说的是Excel 2021,但我设法拼凑出了一些〉几乎〈在Excel 2010中工作的东西。
不幸的是,在这个版本中似乎没有任何方法来连接数组,所以我不得不为那个部分做一个UDF,但我相信新版本中的“CONCAT”函数可能会代替我不得不做的UDF工作。如果有人能为我测试一下,那就太好了x)
LET也会使这个更短...而且这是一个数组公式,所以用ctrl+shift+enter输入

=SUBSTITUTE(myConcat(IF(EXACT(MID(O1;ROW(INDIRECT("A1:A"&LEN(O1)));1);UPPER(MID(O1;ROW(INDIRECT("A1:A"&LEN(O1)));1)));UPPER(MID(O1;ROW(INDIRECT("A1:A"&LEN(O1)));1));""));" ";"")

“作弊”部分是myConcat,其他部分都是用公式构建。

Function myConcat(ByVal arr As Variant) As String
    For i = LBound(arr) To UBound(arr)
        For j = LBound(arr, 2) To UBound(arr, 2)
            myConcat = myConcat & arr(i, j)
        Next j
    Next i
End Function
  • 不幸的是,数字和特殊字符会把这个问题抛到九霄云外。我可能能弄清楚数字,但不确定特殊字符。

相关问题