How do I export text from an excel cell with alphanumeric values into another column?

匿名 (未验证) 提交于 2019-12-03 02:42:02

问题:

I have several cell entries in column B. They look similar to this:

1050670||Target Optical  4226||6132||7132 1051752||Wal-Mart Vision Ctr  305095||6132||7132 1052470||Wal-Mart Vision Ctr  301891||6132||7132 1054354||Naval Ambulatory Care Ctr||6132||7132 

I need a formula that will extract only the text containing the name. Ideally it would look leave me with only:

Target Optical Wal-Mart Vision Ctr Wal-Mart Vision Ctr Naval Ambulatory Care Ctr 

Any help is GREATLY appreciated.

回答1:

If you want to disregard the numbers within the Text pseudo-field, you will have to parse the split-out value closely for characters within ASCII 48-57.

That ugly formula in B1 is,

Fill down as necessary. As bad as it looks, the calculation load on a medium array formula would dwarf it but the INDIRECT does make it volatile so get your stripped values and Copy, Paste Special Values back to remove the formulas.



回答2:

If one of your entries is in B1, use the formula

=MID(B1,FIND("||",B1)+2,FIND("||",B1,FIND("||",B1)+2)-FIND("||",B1)-2) 

Copy and paste as needed. Be careful about relative/absolute referencing.

Of course, there are other options with VBA, but you specifically requested a formula.

If you needed later items between "||"s, the formula that I posted could be adapted, but it could become quite cumbersome. VBA can be simpler. Or you could use

=MID(B1,FIND(CHAR(1),SUBSTITUTE(B1,"|",CHAR(1),(A6-1)*2))+1,FIND(CHAR(1),SUBSTITUTE(B1,"|",CHAR(1),A6*2))-FIND(CHAR(1),SUBSTITUTE(B1,"|",CHAR(1),(A6-1)*2))-2) 

It is cumbersome as well, but it works for "any" item number (there is an upper limit, of course; I did not test it). This is an adaptation from here. A6 contains the item # you want to pick. In your case, it is 2. If you put three, you obtain "6132" for your first line. This formula has to be modified for suitable finding the first or last items.

EDIT: these formulas do not remove the numbers at the end of the target field. I missed this point, but I will leave the answer, as it may be useful for other readers. See the solution by Jeeped.



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