Forum Discussion

anupambit1797's avatar
anupambit1797
Iron Contributor
May 25, 2023

Text After Delimiter

Dear Experts,

                     Could you please help in below Query:-

In Attached Excel, I want my data like in Column "B" only the Text after 4 spaces(Item xx), then in Column "C" the text after 8 spaces(so BandCombination), and so on but when I apply the Formula it takes into account all space conditions and not restricts to 4 or 8 ..

Thanks in Advance,

Br,

Anupam

16 Replies

  • Patrick2788's avatar
    Patrick2788
    Silver Contributor

    anupambit1797 

    Maybe I'm simplifying things a bit too much (or not understanding the goal here) but if the objective is to pull the text after the leading spaces (which might be 4, 8, 12 spaces, etc). Why not use TRIM?

     

     

    =TRIM(A2)

     

     

  • anupambit1797 

    One option for shortening formulas is to build them from Lambda functions.  For example a function to determine how many leading spaces exist might be 

    = Indentλ(string)
    
    where the formula defining Indentλ
    = LET(
        initialCharacter, LEFT(SUBSTITUTE(string," ",""), 1),
        FIND(initialCharacter, string)
      )

     

    • anupambit1797's avatar
      anupambit1797
      Iron Contributor

      PeterBartholomew1Can you please explain this by all the steps you perform? probably in any doc with Screen shots of the the steps we need to perform?

       

      Thanks & Regards

      Anupam Shrivastava

      • PeterBartholomew1's avatar
        PeterBartholomew1
        Silver Contributor

        anupambit1797 

        The main point is that such formulas only work with Excel 365.  The solutions offered by Lambda are not remotely similar to any traditional spreadsheet formula.  What a named Lambda function does is allow you to show the intent of a formula without exposing anything of how it is achieved.

         

        In fact, I changed the formula 'Indentλ' to

        = LAMBDA(string,
              LET(initialCharacter,  LEFT(TRIM(string), 1), 
              FIND(initialCharacter, string))
          )

        but it does not change anything on the worksheet.  I simply posted to suggest a possible avenue to take to make spreadsheet formulas more intelligible, though not always more concise.  If you don't have 365, then it is back to something more traditional!

        [perhaps not that far back?]

         

        The attached workbook illustrates the type of tricks that are now possible.

  • peiyezhu's avatar
    peiyezhu
    Bronze Contributor

    anupambit1797 

     

    select *,replace(supportedBandCombinationList,'    ', '</td><td>') a from split_one_cell_to_multiple;

     

  • anupambit1797 

    Problem is that if a cell begins with 16 spaces, it also begins with 12 spaces and with 8 spaces and with 4 spaces.

     

    In B2:

     

    =IF((LEFT($A132,4*COLUMN()-4)=REPT(" ",4*COLUMN()-4))*(MID($A132,4*COLUMN()-3,1)<>" "),MID($A132,4*COLUMN()-3,1000),"")

     

    Fill to the right to for example H2, then fill down.

Resources