Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

split() function skips blanks

In A1 cell I have A,B,C,,E. I want to split the cell into five cells: A , B, C, , E

This formula =split(A1,",") splits into four cells A, B, C, E and skips over the blank.

How do I tell it to split "properly"?

like image 321
jason Avatar asked Mar 31 '26 16:03

jason


2 Answers

I don't think you can specify that directly, though here is a workaround:

  1. Add another delimiter character to your string. So replace , with say ,|
  2. Now when you split with ,, we know for sure that even empty columns will have a character (in this case |)
  3. Use replace to substitute the extra delimiter | with a blank string
  4. Since output of split is an array, you will need to use arrayformula

Here is what the final formula would look like

=arrayformula(substitute(split(substitute(A1,",",",|"),","), "|",""))
like image 169
Konstant Avatar answered Apr 02 '26 13:04

Konstant


If you use FALSE as the fourth argument, it will work as expected. Try using

=SPLIT(A2,",", TRUE, FALSE)

and you won't need to do work arounds

the output for above formula

like image 34
Shan Avatar answered Apr 02 '26 13:04

Shan