VLookup Function Trouble
Posted by N. Shockley on January 19, 2001 11:50 AM
I need help with using the VLOOKUP function. Maybe I'm using it improperly, maybe not, but I am not getting the results I want.
Here's my spreadsheet:
I've got a lookup table, range AG12 to AJ121. It's made up of 4 columns - Region Code, Customer, Volume, and Net Price. It's sorted by Region Code and then by Customer Name. I will be updating the data every month, and have built a section into my spreadsheet that will hopefully be grabbing the data in my lookup table by REGION, and putting it in the appropriate region section.
For example, one of the region code values is "MA". I want to pull out all MA region code data from my lookup table and put it in the MA section. So in cell C185, I've got "MA". In cells D185, E185 and F185, I've got the vlookup functions, hoping to return all data rows from my look up table with region code of MA, thus returning customer, volume, and net price, respectively. I will be doing the same for all other regions, for example, "MW", "NE", and "EX", in similar sections of spreadsheet.
Here's my formula for Customer, in cell D185:
VLOOKUP($C$185,$AG12:$AJ$122,2,FALSE)
Here's my formula for Volume, in cell E185:
VLOOKUP($C$185,$AG12:$AJ$122,3,FALSE)
My formula for Net Price is same as above, except 4,FALSE.
Okay, I copied my formulas down, of course. It returns the first customer for MA region correctly, and I have no problem with getting the correct volume and net price values for each customer. The second line
down returns the same value as above. Then the third line down and on returns different customers correctly. For example:
1) A & P Tea 200 .0211
2) A & P Tea 200 .0211
3) A. M. Briggs 400 .0503
4) Albertson's 300 .0450 and so on....
The problem here is, my first returned row was repeated incorrectly.
The next problem I have is bigger. I've set up a second section where I want to do a return from my lookup table on all data with region code values of "MW". So in cell I185, I've got "MW". Then in cell J185, K185, and L185, I've got my vlookup functions written exactly the same way as the ones listed above. Now I want all customers from my lookup table returned here, with a region code value of "MW". What I'm getting is this:
1) All Seasons 200 .0403
(Correct, this customer is the first customer in my lookup table with a region code of MW, which in my lookup table is on line 31.)
2) All Seasons 200 .0403 then keeps repeating on down my list.
This sums up my problems. I would appreciate any help you can give. I really need to get this function to work correctly for me, it will save me a lot of work in the future (cutting and pasting gets old.)
Thanks, N. Shockley