Concatenate values based on criteria

后端 未结 2 1404
暖寄归人
暖寄归人 2020-12-12 04:44

I have a two column list of data in Excel. The first column being a question number from a test and the second column being a number referencing what is being tested on that

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-12 04:54

    By nature, Excel discourages this in worksheet formulas. I guess they figure that if you do this in a User Defined Function (aka UDF) and it hoops a workbook, it is your own fault and so be it. To that end, I've never seen a standard or array formula using only native worksheet functions that accomplishes this on a 'ragged-edge' array of cells and it's been tried a few times. Consider it #REF! by design.

    You can run successive IF functions (up to 64 by xl2007+ standards) to accomplish the string stitching (see this) but you will also be limited to the total length of a formula (see this). We also used 'helper' cells to run off the first 7 IFs in <=xl2003 then reference that cell in the first IF of another 7 nested IFs (rinse and repeat).

    TLDR; In short, VBA is your most viable solution (see this). Conditional string concatenation is fraught with problems by itself let alone in an array loop.


    CONCATENATE function

提交回复
热议问题