Board logo

標題: 搜尋字串字數,如何下公式呢? [打印本頁]

作者: gaishutsusuru    時間: 2021-8-3 07:58     標題: 搜尋字串字數,如何下公式呢?

[attach]33816[/attach]

大家早,

想請問如圖的F2~F4公式,該如何下才能顯示值呢?

F2想搜尋有包含1~10的字串,而我用COUNTIF($A$2:$A$4,E2&"*"),卻無法找出值,不知道問題出在哪?


附上檔案:[attach]33815[/attach]


想麻煩各位協助提供想法,謝謝您們。
作者: ML089    時間: 2021-8-3 08:52

=COUNTIF($A$2:$A$4,"*"&SUBSTITUTE(E2,"~","~~")&"*")
作者: 准提部林    時間: 2021-8-3 10:08

1~10
91~100
會有錯誤~~

陣列:
=COUNT(FIND(", "&E2&",",", "&A$2:A$19&","))

嚴謹些:
=COUNT(FIND(","&E2&",",","&SUBSTITUTE(A$2:A$19," ",)&","))
作者: ML089    時間: 2021-8-3 11:11

2樓公式修正
=SUM(COUNTIF($A$2:$A$19,{"","* "}&SUBSTITUTE(E2,"~","?")&{"";",*"}))
分隔符號為 "," + " "(空格)

資料分隔格是要統一,不然COUNTIF函數統計容易出錯,可以參考3樓 嚴謹公式
作者: ML089    時間: 2021-8-3 13:42

增加邊界狀況判斷,減少資料格式不一樣錯誤
=IF(E2="","",SUM(COUNTIF(A:A,{"","* ","*,"}&SUBSTITUTE(E2,"~","?")&{"";" *";",*"})))

增加3種邊界判斷  ""," ",","
作者: gaishutsusuru    時間: 2021-8-3 14:38

感謝ML089和准提部林的熱心幫忙,公式可以使用!




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)