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

后端 未结 3 1750
深忆病人
深忆病人 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:01

    You may also use the below formula if you wish to. It does not use the Indirect function.

    =MID(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2),1,IF(ISNUMBER(VALUE(MID(SUBSTITUTE(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2)," ","¶",LEN(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2))-LEN(SUBSTITUTE(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2)," ",""))),FIND("¶",SUBSTITUTE(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2)," ","¶",LEN(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2))-LEN(SUBSTITUTE(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2)," ",""))))+1,50)))=TRUE,FIND("¶",SUBSTITUTE(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2)," ","¶",LEN(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2))-LEN(SUBSTITUTE(MID(A1,FIND("||",A1,1)+2,FIND("||",A1,FIND("||",A1,1)+2)-FIND("||",A1,1)-2)," ",""))))-1,50))

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-26 11:28

    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.

          Text Only parsing

    That ugly formula in B1 is,

    =TRIM(LEFT(MID(A1, FIND("||", A1)+2, FIND("¶", SUBSTITUTE(A1, "||", "¶", 2))-FIND("||", A1)-2)&0, MIN(INDEX(ROW(INDIRECT("1:"&LEN(MID(A1, FIND("||", A1)+2, FIND("¶", SUBSTITUTE(A1, "||", "¶", 2))-FIND("||", A1)-2)&0)))+((CODE(MID((MID(A1, FIND("||", A1)+2, FIND("¶", SUBSTITUTE(A1, "||", "¶", 2))-FIND("||", A1)-2)&0),ROW(INDIRECT("1:"&LEN(MID(A1, FIND("||", A1)+2, FIND("¶", SUBSTITUTE(A1, "||", "¶", 2))-FIND("||", A1)-2)&0))),1))<48)+(CODE(MID(UPPER(MID(A1, FIND("||", A1)+2, FIND("¶", SUBSTITUTE(A1, "||", "¶", 2))-FIND("||", A1)-2)&0),ROW(INDIRECT("1:"&LEN(MID(A1, FIND("||", A1)+2, FIND("¶", SUBSTITUTE(A1, "||", "¶", 2))-FIND("||", A1)-2)&0))),1))>57))*1E+99,,))-1))
    

    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.

    0 讨论(0)
提交回复
热议问题