How to return array() in vba function to use it in cells Array formulas (matricial formula) : for split texte in multi cells

后端 未结 3 1350
故里飘歌
故里飘歌 2021-01-06 04:10

I\'m writing a function in VBA to use in excel formula, it\'s ok if my function return a single value:

=MYVALUE(A1)

Now I wrote another fu

3条回答
  •  独厮守ぢ
    2021-01-06 04:41

    Array formulas need use like that

    my VBA to split text in multi cells

    Function EXPLODE_V(texte As String, delimiter As String)
        EXPLODE_V = Application.WorksheetFunction.Transpose(Split(texte, delimiter))
    End Function
    Function EXPLODE_H(texte As String, delimiter As String)
        EXPLODE_H = Split(texte, delimiter)
    End Function
    
    1. Select region C3:C7 this define the vector direction.
    2. Press F2 to edit on the spot and type the following formula: =EXPLODE_V($B$3;" ")
    3. Press CTRL+SHIFT+ENTER ( INSTEAD of usual ENTER ) - this will define an ARRAY formula and will result in {=EXPLODE_V($B$3;" ")} brackets around it (but do NOT type them manually!).

      sample of split cells texte

提交回复
热议问题