welcome to Excel magic number 1107. If you want to download this file, click on the link below the video. Hey, we have a great video here. We want to do something simple, but we want to see three different ways to do it. Here's our data set, and check this out: we have sales rep, and there's a huge data set. Control down arrow, so it's like 10,000 records, and there's lots of repeats here. We need to get region for each one of the sales reps from using VLOOKUP in this cell right here, from this table. This table, Ctrl+Down Arrow, has 73 records, because we have 73 sales reps, and some of them sell in the Midwest, some of them sell in the West and East. So we need to populate this column here with region, doing a VLOOKUP three different ways. We can do this. Now, the first way we're going to do is sheet references, and then we'll learn how to use defined names and even the table feature.
All right, so VLOOKUP: we say, hey, what's our lookup that we need to look up? Sales rep, and that's a relative cell reference as we copy down. Comma, and here's the problem: the table is on the other sheet. No problem. We're used to highlighting a table here and hitting F4, right? But how do we do that? Click right, because it's a cell on this sheet. Here, I'm going to delete that. Click delete. All we have to do to get the cells on the different sheet is first click the sheet you want, so now SR. Now we can see up in the formula bar the formula is starting to emerge. The sheet name is in single apostrophes, and then we have an exclamation point. That exclamation point says, hey, this is a sheet reference. That means that word is okay in a formula. It's not a function name or defined name; it's a sheet reference. Now we simply highlight the table. Sometimes people are tempted to go like this. I kind of stay away from that, because there are a lot of cells in there that I'm unnecessarily highlighting. I'm going to click in the top cell. Notice it says A2 and B2, and it's actually not the top cell. I'm going to use the keyboard: Ctrl+Shift+Down Arrow. That sends it all the way down. Notice up in the formula bar it's still relative, so now I hit F4. Now I'm going to come up and finish this formula, because I'm actually on the sheet right here. What we don't want to do is click back on the other sheet. If you're doing the sheet reference, I'm going to click up here. Notice "table_array"; the screen tip tells us. Comma, column index is 2, because I want to take the region from here. Then comma, and I'm using 0 for exact match. This table actually is sorted, but just to be sure, in case it gets unsorted, I'm going to put exact match, and now I can hit Enter. Just like that. If I come back here and hit F2, there's that beautiful sheet reference. All right, Control+Enter, double-click, and send it down. Control+Down Arrow to go to the bottom, and sure enough, it worked all the way down. Control+Home to jump back to cell A1.
Now, another way we could do this, and I'm going to copy both of these, Control+C, Control+V, and delete, is we can go over to the table on the SR data sheet. Control+Home, Ctrl+Asterisk on the number pad to highlight this whole table. Go up to the Name Box, highlight "A1," and I'm going to type "sales rep table," Enter. Now I'm going to click off to the side and verify by using my drop-down. Now I'm going to scroll down, and I can already see I made a mistake. Scroll up. You see how I included the field names? I don't really want those field names. We can go to the Formulas ribbon, Name Manager. Sometimes you need to edit this. Notice there's a keyboard shortcut, Ctrl+F3. I'm going to click there and edit. I only want "A2," so I'm going to change just that, right here. I could have deleted it and started over, but now I'm going to verify. Click OK, and watch this. I'm going to verify by clicking this collapse button, and sure enough, it looks like it got the right range. Uncollapse, click Close. Now I can come over to the first sheet: equals VLOOKUP, hey, there's the sales rep. I scroll over here to give us a little more room. Comma, and we can type if we know the name, and look at that, it came right up in the drop-down field with functions, and a tag for our defined names. Once I highlight it, I can simply hit Tab. If you don't remember at all what it is, hit the F3 key. There's also up in the formula ribbon, because formulas have the defined names. You can say "Use in Formula," but I'm going to remember F3, and it will give me a list of all of them. Double-click it, and I insert it. Comma, 2, comma, 0, close parentheses. Then Ctrl+Enter, which puts the thing in the cell and keeps the cell selected, and then double-click and send it down. That's totally cool.
Now, there's a third way we can do this. Let's do the table formula. Come over to this sheet, SR table, and we want to convert this to a table. When we convert it to a table, it does all sorts of amazing things, including giving us table formula nomenclature. You either go up to Insert Table or use the keyboard shortcut Ctrl+T, and you have to have field names at the top and records in rows, which we do here. Technically, you don't, but it'll put in columns. So this trick is going to work when you have a proper data set. I'm going to click OK. Now we want to immediately come up to Table Tools Design, come over to Properties, and give this table a name. I'm going to call it "sales rep region table," actually just without the table: "sales rep region," Enter. The table feature has dropdowns for sorting and filtering, and it's pretty amazing. If you add records to the bottom, this table will update, and that VLOOKUP will update as well. Control+Home. But now we want to learn about table formula. Let's come over to the sheet 107 TF, and let's just build our VLOOKUP.
All right, so I'm going to click on lookup value, comma, and now I'm going to start typing "sales." We can immediately see three different icons: function, a tag, that means defined name, and there's that table. That won't work, that's the whole table. You have to type a square bracket to get a dropdown. This is table formula nomenclature, also known as structured references. Now we can refer to fields, which we don't want here. We want the whole table, so I'm going to say "data." Data is the whole table, and we might go prove that to ourselves in just a moment. I'm going to close parentheses, and that is referring to that other table on the other sheet. Sometimes people like it because, as long as you know the table name, you can get any one of the columns, or the headers, or the data you want from any other sheet by typing it out and then a square bracket. Comma 2 for VLOOKUP, that means the second column has the thing we want to return. Comma FALSE, or 0, I'm using 0 for false, exact match. Control+Enter, double-click, and send it down. That is totally cool.
Now let's come over here and prove that to ourselves. Equals "sales," and we see this. I'm going to hit Tab, and square bracket, Down Arrow, Down Arrow, Tab, close square bracket. Now you can see the blue outline; that data option gets the inside of the table. The nice thing, of course, about the table is if we were to add any new records, say Yin Pham, and Ian Pham is in the West, that would totally be picked up on this other sheet and change this to, in our example, the West. That didn't prove it. Let's put the South: come over here, boom, there it is. So that table formula nomenclature is pretty cool.
All right, so we saw table formula nomenclature. Back over here we saw defined names, and we saw sheet references, all for getting VLOOKUP to look to another sheet for a table. All right, we'll see you next time.
