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

后端 未结 3 1863
深忆病人
深忆病人 2021-01-26 10:54

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
10         


        
3条回答
  •  渐次进展
    2021-01-26 11:05

    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.

提交回复
热议问题