Simulate string split function in Excel formula

后端 未结 8 1748
难免孤独
难免孤独 2020-12-09 09:15

I am trying to split a string in an excel formula, something like I can do in many programming languages, e.g.

string words = \"some text\".split(\' \');
         


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-09 09:46

    =IFERROR(LEFT(A3, FIND(" ", A3, 1)), A3)
    

    This will firstly check if the cell contains a space, if it does it will return the first value from the space, otherwise it will return the cell value.

    Edit

    Just to add to the above formula, as it stands if there is no value in the cell it would return 0. If you are looking to display a message or something to tell the user it is empty you could use the following:

    =IF(IFERROR(LEFT(A3, FIND(" ", A3, 1)), A3)=0, "Empty", IFERROR(LEFT(A3, FIND(" ", A3, 1)), A3))
    

提交回复
热议问题