ARRAYFORMULA() does not work with SPLIT()

后端 未结 5 1015
离开以前
离开以前 2020-12-05 15:05

Why doesn\'t the split formula get expanded over the entire column when I use =arrayformula(split(input!G2:G, \",\")) ?

I get result only for the input

5条回答
  •  臣服心动
    2020-12-05 15:47

    It can work, but you have to pad and constrain to make it a square result.

    Take this data:

               ColA             COLB
        Row1   Data             ={"Head1","Head2","Head3","Head4","Head5","Head6","Head7";ARRAY_CONSTRAIN(ARRAYFORMULA(SPLIT(A$2:A&" , , , , , , ",",",FALSE,FALSE)),COUNTA(A2:A),7)}
        Row2   1,2,3,4,5,6,7,a
        Row3   1,2,3,5
    

    Gives you this:

               ColA                   COLB
        Row1   Data             Head1 Head2 Head3 Head4 Head5 Head6 Head7 
        Row2   1,2,3,4,5,6,7,a  1     2     3     4     5     6     7
        Row3   1,2,3,5          1     2     3     4     5
    

    This is formula:

    ={"Head1","Head2","Head3","Head4","Head5","Head6","Head7";ARRAY_CONSTRAIN(ARRAYFORMULA(SPLIT(A$2:A&" , , , , , , ",",",FALSE,FALSE)),COUNTA(A2:A),10)}
    

    First we constrain the result to the maximum acceptable results using ARRAY_CONSTRAIN. You can calculate the max value or hardcode it. I used 7 cols and as many rows as counted. ARRAYFORMULA used to run it down. SPLIT text value is padded with empty values to ensure it exceeds the constrain value. This allows accommodation of values in ColA of varying length. FALSE I think will avoid them being trimmed and upsetting the array. Might not be necessary, I didn't test.

提交回复
热议问题