欧博abgExcel, append one range to the end of another

Here is a simple solution using FILTERXML and TEXTJOIN that can append MULTIPLE RANGES OF ANY SIZE, ARRAY FORMULAS AND REGULAR FORMULAS. Just replace YOUR_RANGES with the ranges or dynamic arrays you wish to join:

Simple version that ignores empty cells:

=FILTERXML("<A><B>" & TEXTJOIN("</B><B>",TRUE,YOUR_RANGES) & "</B></A>", "//B")

This one includes empty cells:

=IFERROR(FILTERXML("<A><B>" & TEXTJOIN("</B><B>",FALSE,YOUR_RANGE) & "</B></A>", "//B"), "")

If your input data contains the "<" character, the formulas above will return an error, so use this one instead:

=IFERROR(SUBSTITUTE(FILTERXML("<A><B>" & SUBSTITUTE(SUBSTITUTE(TEXTJOIN("ΨΨ",FALSE,YOUR_RANGE),"<","ЉЉ"),"ΨΨ","</B><B>")&"</B></A>","//B"),"ЉЉ","<"),"")

Note: you can change the FALSE to TRUE to ignore empty cells.

Note 2: You can replace the characters ЉЉ and ΨΨ by any character(s). I used these specific characters because it is very unlikely that your input data will contain ЉЉ or ΨΨ, which would cause errors.

NOTES:

Tested on:

Excel 365

EXAMPLE:

enter image description here

Using the simple version of the formula:

=FILTERXML("<A><B>" & TEXTJOIN("</B><B>",TRUE,A1:A3,B1:B3,C1:C3) & "</B></A>", "//B")

As a result you will get a dynamic array with the joined/appended ranges:

enter image description here

You can then apply any dynamic array formula (like UNIQUE) to the result.

HOW THIS WORKS:

The JOINTEXT function grabs your ranges and joins them as a text with the delimiter "</ B >< B >". Then, after adding "< A >< B >" to the beginning and "</ B ></ A >" to the end, we have an XML formatted text:

<A><B>1</B><B>2</B><B>3</B><B>A</B><B>B</B><B>C</B><B>!</B><B>@</B><B>#</B></A>

Finally, the FILTERXML will separate the tags into a dynamic array which will be the joined/appended ranges.

2026-02-21 04:21 点击量:2