我有一组单元格,字符串的第一个永远不会改变,它是并且总是会改变(直到编码器更改它)20
字符(包括空格)。
然后我想从剩余序列中提取 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
If I &
单元格作为计算的一部分,然后它们不会在下一个数学步骤中进行计算,因为我必须考虑到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
提前谢谢了。