Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2015, 12:42 PM
gebobs gebobs is offline Pivot table or Vlookup or how? Windows 7 64bit Pivot table or Vlookup or how? Office 2010 64bit
Expert
 
Join Date: Mar 2014
Location: Atlanta
Posts: 837
gebobs has a spectacular aura aboutgebobs has a spectacular aura about
Default

There are a few ways to skin that cat.



Absolute referencing
As you've found, copying =VLOOKUP(E2,A4:C7,2,FALSE) changes the range of the lookup table as you copy down. You can use absolute references to handle that. Put a dollar sign in front of the references you want to keep constant. In this case, only the row numbers change so the formula in row 2 can be written as...

=VLOOKUP(E2,A$4:C$7,2,FALSE)

You can make both cell and column absolute in this case (e.g. $A$4:$C$7) and it won't matter. Same for the other VLOOKUP. Now when you copy them, no problem.

Named ranges
The above is fine, but not entirely robust. Naming the range is a bit better and makes the equation more logical. Select your lookup table on the left and use Formula>Define Name. Call you table something descriptive (e.g. PartList) and press OK. The formula can now be written as...

=VLOOKUP(E2,PartsList,2,FALSE)

IMHO, it's best not to have spaces in named ranges.

Format as Table
Even more robust is to use the Format as Table function. Select each table in turn and use Home>Format as Table and select a format you like. As with Ranges, I suggest your column headings not have spaces so I changed MANUFACTURED BY to MANUFACTURER.

Next, use Formula>Name Manager to logically name the tables. Excel automatically names them Table1, etc. which is not descriptive. I named them PartsList and Inventory. I also prefer to have each table on separate sheets, but I'll leave that up to you if you like (easily done with cut/paste). Making each table bigger or smaller is a snap by either right clicking and Insert/Delete or by dragging the little thingee on the bottom right of the table.

Now, when you enter the type the formulas in row 3, Excel automatically populates the cells with the formula all the way down. Look at how the formula looks now...

=VLOOKUP([@OBJ],PartsList,2,FALSE)

So much more logical. Anyhoo, I've attached the finished sheet here. Lemme know if you need more help. I know I've dropped a lot of info on you, but if this sinks in you will be an Excel pro. :-)
Attached Files
File Type: xlsx Test vlookup.xlsx (11.3 KB, 12 views)
Reply With Quote
  #2  
Old 02-20-2015, 12:48 AM
BlueSky BlueSky is offline Pivot table or Vlookup or how? Windows 7 64bit Pivot table or Vlookup or how? Office 2010 32bit
Novice
Pivot table or Vlookup or how?
 
Join Date: Feb 2015
Location: London
Posts: 9
BlueSky is on a distinguished road
Thumbs up

Awesome! Gebobs, you have explained that so well in such a logical step by step way that I'll be able to absorb all that info. I also like the way you think it through to make it as efficient and logical and bullet proof as possible. I get a kick out of making AutoCAD do what I want with Lisp so I'm also pleased to see that Excel can do something like that so well. A very big thank you Gebobs!

Quote:
Originally Posted by gebobs View Post
There are a few ways to skin that cat.

Absolute referencing
As you've found, copying =VLOOKUP(E2,A4:C7,2,FALSE) changes the range of the lookup table as you copy down. You can use absolute references to handle that. Put a dollar sign in front of the references you want to keep constant. In this case, only the row numbers change so the formula in row 2 can be written as...

=VLOOKUP(E2,A$4:C$7,2,FALSE)

You can make both cell and column absolute in this case (e.g. $A$4:$C$7) and it won't matter. Same for the other VLOOKUP. Now when you copy them, no problem.

Named ranges
The above is fine, but not entirely robust. Naming the range is a bit better and makes the equation more logical. Select your lookup table on the left and use Formula>Define Name. Call you table something descriptive (e.g. PartList) and press OK. The formula can now be written as...

=VLOOKUP(E2,PartsList,2,FALSE)

IMHO, it's best not to have spaces in named ranges.

Format as Table
Even more robust is to use the Format as Table function. Select each table in turn and use Home>Format as Table and select a format you like. As with Ranges, I suggest your column headings not have spaces so I changed MANUFACTURED BY to MANUFACTURER.

Next, use Formula>Name Manager to logically name the tables. Excel automatically names them Table1, etc. which is not descriptive. I named them PartsList and Inventory. I also prefer to have each table on separate sheets, but I'll leave that up to you if you like (easily done with cut/paste). Making each table bigger or smaller is a snap by either right clicking and Insert/Delete or by dragging the little thingee on the bottom right of the table.

Now, when you enter the type the formulas in row 3, Excel automatically populates the cells with the formula all the way down. Look at how the formula looks now...

=VLOOKUP([@OBJ],PartsList,2,FALSE)

So much more logical. Anyhoo, I've attached the finished sheet here. Lemme know if you need more help. I know I've dropped a lot of info on you, but if this sinks in you will be an Excel pro. :-)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Pivot Table Question- Can the table display in the order the boxes were checked/selected? blackjack Excel 0 09-13-2014 08:57 PM
Pivot table help TishyMouse Excel 2 04-27-2012 10:19 AM
Pivot table or Vlookup or how? pivot table aliasadi_07 Excel 1 03-11-2012 12:49 AM
Pivot table or Vlookup or how? Help with a pivot table please! natsha Excel 1 02-16-2012 12:41 PM
Pivot table or Vlookup or how? Pivot Table Karen615 Excel 5 08-03-2011 10:46 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft