Convert an Array Formula's Text Results into a Usable Format

前端 未结 5 1283
执念已碎
执念已碎 2020-12-04 01:36

When the results of an Array Formula are numbers, I find it generally easy to find an appropriate method to collapse the array into a single result. However when the results

5条回答
  •  无人及你
    2020-12-04 02:22

    You can create your own aggregate function to handle the results of a formula array. It does require a little VBA... but it's not difficult. This will allow you to do all kinds of string manipulation or numerical analysis on arrays of values.

    To do your concatenation function, open up a VBA code window and create a new module by right clicking on the project -> insert -> new module. Double click the new module and insert this code to create the function that will concatenate an array into one large string:

    Function ConcatenateArray(ParamArray Nums() As Variant) As Variant
    Dim BigString As String
    Dim N As Long
    Dim A() As Variant
    Let A = Nums(0)
    
    BigString = ""
    For N = LBound(A) To UBound(A)
        BigString = BigString & A(N, 1)
    Next
    ConcatenateArray = BigString
    
    End Function
    

    Then change your array formula in the cell to:

    =ConcatenateArray(IF(VALUE(RIGHT($A$1:$A$500,3))>400,$A$1:$A$500,""))
    

    Of course you have to hit CTRL + SHIFT + ENTER instead of just ENTER to confirm the cell as an array formula.

提交回复
热议问题