Welcome to Excel Magic Trick number 1,114. If you want to download this workbook for 1113 to 1115, click on the link below the video. In this video we have a great trick, but first I want to tell you about two links. One is Charles Williams, an Excel MVP and one of the smartest Excel people in the world, who has published all sorts of amazing things. This article is one that I quoted extensively in my Control Shift Enter book. It is well worth reading. It tells you how to improve formula performance and covers all sorts of interesting things about volatile functions. It even has code you can copy and paste: if you go down a bit, there it is. You paste it in and you have a timer in your workbook, so you can time any of your formulas. This article and some of the links on the side show how much awesome information there is. Another link is XLTV. They just had Sylvia on, The High Priestess of Excel, and there is an amazing history of Excel. You should go to this link, or just go to the XLTV channel.
All right, we have a sequential set of numbers here. Notice we're counting from 18440, and there are 51s until we get to 50 records, and then we start at 2. Notice 8, 18489, 1849 0. So it looks like the numbers in the first part of this text string are consecutive sequence numbers, always adding one, but here we need to repeat 51s, then 52s, then go to three, and so on. Let's see how to do this. The inside of most sequential number formulas is either rows or columns, and you use an expandable range. I just want a formula element that counts 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 onward. I'm in B2, so I type B$2. I'm locking the row 2 because I'm copying it down the rows. B$2:B2 is an expandable range. ROWS just says how many rows there are from 2 to 2, but that 2 is free to roam. So Control+Enter, double-click, and send it down. At any point you can see that 4 is allowed to increase. ROWS of 2 to 5 gives four. Now let's subtract one, because we're going to need this. Remember, we need to repeat one 50 times, so I'm going to start by subtracting one. If we go down and look at 50, it now needs to start the next number. No problem. Consider all of these numbers up to 50: what if we divided this by 50? I'm going to hardcode that in. We could easily put it off to the side in an assumption cell, which I'll do for this, but we're going to assume this won't change. What will this do? For the first 50, it will always give some number between zero and one. Look at that all the way down. So one is the first instance of the next number.
Now we can use the INT function. INT always goes down; it gives the integer. So these will all be zero, 1, 1.02, 1.04 will all be one. I'm going to use INT, which means give me the integer. Control+Enter, double-click, and send it down. Now all the way down, perfect. Look at that: 0000, well, almost 0. 01. The ones are for two, so we simply have to add one, and that will work all the way down. I hit F2 to put the cell at the top in edit mode and edited it. Now I Control+Enter to populate this formula all the way down, and there we have the last part. You can see that's working fine. Now we need to add some to this. I'm going to click on the start number and press F4, and I'm going to steal this little part, because I always need to add one. That has to increment all the way down, so plus, and since I did ROWS minus one, that gives me 0, 1, 2, 3, all the way down. I need to join these two different calculations, so I'm going to use the ampersand. I need a space between them, so I put a space in double quotes, then an ampersand. This is going to be a text string, with one part before the first ampersand, then a space, and then this after it. Control+Enter, double-click, and send it down. Look at that. I can't believe it, it's working all the way down. We get to our change here, and now it goes 2, 2, 2, 2, 2, and the numbers at the beginning are incrementing perfectly. Control+Up Arrow.
Now let's change the start number to 1852, and instantly look at that. In fact, that's so fun to do, let's change this. I'm going to click on it, then down arrow. Right now it'll be a zero, but I'm going to press F4, Control+Enter, and then put a 50 here. I'll right-click, point to the formatter, click there to paste just the formatting, and say repeat. Now check this out: we could type 5, double-click, and send it down. Now it repeats with the new starting number and new repeater: 1, 2, 3, 4, 5, 1, 2, 3, 4, 5. That is absolutely beautiful. So 1844, 50, back to our original sequential set. All right, be sure to check out Charles Williams' amazing article on performance, and then this amazing video on the history of Excel. All right, we'll see you in the next video.
