transcript

excelisfun - Append Multiple Columns with Excel Dynamic Spilled Array Formula. Excel Magic Trick 1646.

Thumbnail of the video “excelisfun - Append Multiple Columns with Excel Dynamic Spilled Array Formula. Excel Magic Trick 1646.”
Download Markdown
Community upload. AI output has not been independently verified.

A pen multiple columns with a dynamic array. Well, in 1644 we saw how to do this with two columns, and in that video we saw that Power Query is the easiest method. Well, our friend Bill Sis suggested a formula that, if we add an item to this third list, all three lists plus any new data are included. Now, in the comments below video 1644, there were a bunch of cool dynamic array formulas for two different lists, and you can check those out here. But in this video, 1646, we want to take one, two, or three different tables and mash them all together in a single column.

Interestingly enough, the first thing we're going to do is take one, two, three columns and mash them together into a two-way table with three columns. The lookup function we can use to look up three columns and display them side by side is CHOOSE. Now, INDEX usually expects a one, a two, or a three, and then it goes and gets either value one, two, or three. But we want all three columns simultaneously, so we use array syntax: open curly bracket 1, comma, 2, comma, 3, close curly bracket. So INDEX has: please go get all three items simultaneously, comma, value 1, which is the name of the first column, Name 1, comma, value 2, which will be named 2, comma, and then Name 3. Now when I close the parenthesis, it's very important: for the index number we used array syntax and commas. Array syntax with commas means go over a column. If we had used semicolons, that would mean rows, and would have picked out this item from rows 1, 2, and 3, but that's not what we want, so we use the correct syntax. Now, because CHOOSE delivers a table, when I hit Enter there's our table. Very importantly, any cell click in the formula is grayed out; it only lives in the top left corner. There it is. We can see our formula. Now we have a two-way table with rows and columns, so we can create our INDEX formula. An array will have the table. All we need now is the correct row and column number. We'll create the row and the column here as dynamic arrays so the formula spills.

But before we do that, what do we need? As we copy down, we need one, two, three, four, five, six, seven, eight row numbers for column one. Then when we get to row nine, I need to repeat one, two, three, four, five, six, seven, eight, but all for column two. So here I need one through eight three times, and here I need a bunch of ones and a bunch of twos, and so on. Now we're in the new Excel, so we get to use SEQUENCE. It'll generate any sequence of numbers we can dream up. Now, I need to count how many cells are here: eight times three, 24. So I'm going to do that using the ROWS function, and watch this: I'm going to refer to the formula in F3 and everything that's spilled by using the pound symbol. That's eight times columns, F3 pound, right? So if we were to highlight this and hit F9, we get 24. Now I'm going to leave all the arguments out just for the moment, and we can see from that top cell it spills. Now I need to convert this to one, two, eight, one, two, eight. F2. Now we click back in SEQUENCE. I can see rows, so I type a comma. We do not need a columns argument, so comma, and for the start argument I want the sequence to start at zero. Now when I hit Enter, the sequence starts at zero and goes to 23. Now I have zero to seven, where I need one, two, eight, and then eight to fifteen, where I need one to eight. Well, guess what? If we divide all these numbers by the number eight, which is the number of rows over here, and ask for the remainder, I'll get zero, two, seven, zero, two, seven, and so on. So in the top cell I use the MOD function. There's number, no, it just needs the divisor or denominator, ROWS of F3 pound. Close the parenthesis, and MOD will give us the remainder of doing that division. So Enter. Now I just need to add one, and I have what I want, and it will spill one, two, eight, one, two, eight. Those are the row numbers we'll use in INDEX.

Now we need the column numbers, and it's going to be similar. We'll copy SEQUENCE, Ctrl+C, equals, Ctrl+V. Now at the end I want to click inside SEQUENCE. We're going to start at zero, but when we type a comma, we want the step to be a little bit, so: zero, almost all the way up to one, and the little bit we want is 1/8, which is however many rows are in the spilled array. Close the parenthesis. Now, because it's 1/8, if we F9 it we get 0.125. Control+Z. When I enter this, look at that: I almost have what I want, zero up to 0.875. If I simply add one, F2, plus one, and when I enter, now I have one all the way up to 1.875. That's almost what we want, because ones represent the first column, then twos represent the second column. Now we could use the INT function or TRUNC or something to get out the ones and the twos, but guess what? Over here, when we use INDEX, INDEX is programmed so that when it sees a row or column number, it only takes the integer part. So watch this. Equals INDEX. We need, for the array, F3 pound, comma, then for the row number, here's the rows, all of them, so we use the pound symbol, and the column numbers, pound. Now when I close the parenthesis and hit Enter, we almost have what we want. It's just the #N/As that are messing this up. Well, we can filter those out using the FILTER function. I'm going to have to use this twice. Control+C. FILTER is one of these new, amazing dynamic array formulas. So there's the array we want to filter, and guess what? I want whatever is not #N/A, so I use NOT, and then ISNA. Control+V. Now I close the parentheses, close the parentheses, so INCLUDE will have the TRUEs and FALSEs to get at just the names, and that will filter the first argument. Now when I hit Enter, that is absolutely amazing. If I come over here and here's Ty, Enter, absolutely beautiful. Controls easy: if I change this and it's just Sue and GG, well, that's a mess there, but not here. Now you could hide all this, or we could mash it all together. When you do, what Bill Sis did, he took this table that we created, created a defined name, and then mashed everything together.

Alright, we saw how to use CHOOSE to put multiple columns side by side, MOD and SEQUENCE to generate the numbers one to eight, SEQUENCE to generate column numbers, and that cool formula to mash it all together and append one on top of the other. Alright, thanks to Bill Sis for that amazing trick. And of course, if you liked that video, be sure to click that thumbs up, leave a comment, and subscribe, because there's always lots more videos to come from ExcelIsFun. And if you want to learn a lot more about dynamic arrays, check out this comprehensive introduction to Office 365 dynamic arrays.