Excel formula to find a specific number in variant variable

前提是你 提交于 2020-05-17 05:57:10

问题


I have the following

how can i get the sum number from T1 example or A1?

The Variable in Column A can be variant.

Result in C2 should count how many T1 in Column A or how many A1 in Column A and so on for other Values.


回答1:


Try following array formula:

=SUM(IFERROR(SEARCH(C1,RIGHT($A$1:$A$12,LEN(C1)))*((SUBSTITUTE($A$1:$A$12,C1,""))),0))+COUNTIF($A$1:$A$12,C1)

Array formula after editing is confirmed by pressing ctrl + shift + enter




回答2:


As a follow-up on this older question I believe you could try the following:

Formula in C2:

=SUM((ISNUMBER(SEARCH("*"&B2,A$1:A$12)))*(IFERROR(LEFT(A$1:A$12,SEARCH(B2,A$1:A$12)-1)*1,1)))

Beware that this answer is applicable to the sample data provided but will fail when you start having data as T11 etc. However, you haven't provided any further information so hopefully this will do.


A much more solid solution could be to use some XPATH:

=SUM(IFERROR(SUBSTITUTE(FILTERXML("<t><s>"&TEXTJOIN("</s><s>",1,A$1:A$12)&"</s></t>","//s[substring(., string-length(.)-"&LEN(B2)-1&")='"&B2&"']"),B2,"")*1,1))

Note: Confirm both options through CtrlShiftEnter




回答3:


You can try below formula and see if it helps.

=SUMPRODUCT(IF(RIGHT($A$1:$A$12,LEN(B2))=B2,LEFT("0"&$A$1:$A$12,LEN($A$1:$A$12)+1-LEN(B2))+($A$1:$A$12=B2),0))

Copy down as much needed.



来源:https://stackoverflow.com/questions/61655039/excel-formula-to-find-a-specific-number-in-variant-variable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!