作者:houjiajun | 来源:互联网 | 2023-05-21 20:42
我有一组单元格,第一个字符串永远不会更改,它始终会(直到编码器更改它)20
字符(inc空格).
然后我想从剩余的序列中提取3个数字(在某些情况下为2).
The monthly cost is 2 silver, 1 copper and 40 iron.
The monthly cost is 1 silver, 94 copper and 40 iron.
The monthly cost is 1 silver and 75 copper.
The monthly cost is 8 silver and 40 copper.
The monthly cost is 1 silver.
The monthly cost is 99 silver, 99 copper and 99 iron.
The monthly cost is 1 gold.
在上面的示例中,您可以看到前20个字符后没有设置值.
1 or 99 silver
1 or 99 copper
0, 1 or 99 iron
我无法得到一个能让所有细胞都正确的序列,我尝试过以下方法:
=IF(J7<>1,(MID(TRIM(J7),FIND(" iron",TRIM(J7))-2,FIND(" iron",TRIM(J7))-FIND(" iron",TRIM(J7))+3)),"")
results in: #VALUE! (when no iron)
=TRIM(MID(J6,FIND(" silver",J6)-2,LEN(J6)-FIND(" silver",J6)-26))&TRIM(MID(J6,FIND(" copper",J6)-2,LEN(J6)-FIND(" copper",J6)-16))&TRIM(MID(J6,FIND(" iron",J6)-2,LEN(J6)-FIND(" iron",J6)-3))
results in: 1 s9440
=MID(J7,31,2-ISERR(MID(J7,21,1)+0))
results in: nd
如果我&
将单元格作为计算的一部分,则它们不会在下一个数学步骤中计算,因为我必须允许spaces
在我的代码中,在可能有2位数字而不是单个数字的情况下.
=MID(J5,SEARCH(" silver",J5,1)-2,2)&MID(J5,SEARCH(" copper",J5,1)-2,2)&MID(J5,SEARCH(" iron",J5,1)-2,2)
results: 2 140
not: 2140
我最终需要的是:
2140
19440
175
840
1
999999
提前谢谢了.
1> barry houdin..:
这个公式对我的数据有用,假设单元格A1中有文本字符串
=IFERROR(MID(A1,SEARCH("silver",A1)-3,2)+0,"")&IFERROR(MID(A1,SEARCH("copper",A1)-3,2)+0,"")&IFERROR(MID(A1,SEARCH("iron",A1)-3,2)+0,"")
我假设你不想要"黄金"的价值?