Solved

Excel Vlookup return a formula relative to current sheet

Posted on 2011-09-18
11
318 Views
Last Modified: 2012-05-12
Hi Experts.

Consider this scenario.

A vlookup on Sheet1 returns a value from Sheet2.  The cell it successfully finds and returns on Sheet2 is this formula    =E1&” is good”

I want the vlookup to display that on Sheet1 and the formula to look at E1 on Sheet1.  Currently it’s still referring to E1 on Sheet2.

Obviously if the formula on Sheet2 was  =Sheet1!E1&" is good"  then the result of vlookup would work but I want to use Sheet2 to be accessed from multiple sheets.  Therefore Sheet2 must stay generic and refer to E1 and the other sheets will each have the correct value in their own E1.

A simple example is attached.  

How do I achieve this?  I hope my question is clear.

Thanks,

Will

vlookup-help.xlsx
0
Comment
Question by:willnjen
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 50

Expert Comment

by:teylyn
ID: 36558445
Hello,

Sorry, I'm confused. What do you want where?

On Sheet1 you look up a value from Sheet2. So far so good.

Do you want in Sheet1, B1

=E1&VLOOKUP(A1,Sheet2!A1:B3,2)

Can you post a sample with several sheets and the desired results in each sheet?

cheers, teylyn
0
 
LVL 41

Expert Comment

by:dlmille
ID: 36558478
My two cents.

I don't think you need the reference to E1 in Sheet2.  You just need the factor (e.g., 1,2,3) and the results of that factor (e.g., good, average, bad)

Then, from any other sheet in the workbook, you can use the formula (example below pasted in A1, having a name in E1:

=E1 & VLOOKUP(A1,Sheet2!$A$1:$B$3,2,0)

Thus, the name in E1 is the first, then the result of looking up A1 in the table Sheet2!A1:B3, returning column 2 with exact match 0.

You can copy this formula pretty much anywhere, where Vlookup(A1 <- that points to the factor of 1,2,3 and E1 <- that points to the person's name.

I hope I'm adding clarity here.

See example spreadsheet where I made slight changes, and added another sheet tab with names and factors/ratings, so you can see it play out.

Cheers,

Dave
vlookup-help.xlsx
0
 

Author Comment

by:willnjen
ID: 36558482
Hi Teylyn

Have a look at the file vlookup-help2.xlsx attached to this answer.  There are two sheets in the file.

Cheers,

Will  vlookup-help2.xlsx
0
 

Author Comment

by:willnjen
ID: 36558502
Hi Dlmille

Sorry, I think I've simplied my example too much.  In reality, the cell returned by the vlookup will be something like....

"Jim is good. He is able to do stuff.  Jim is always working hard".  

That will be a formula like

=E1&" is good. "&E2&" is able to do stuff. "&E1&" is always working hard"

E2 will be a He/She if Jim is a boy or girl.

All that info of name and boy/girl will be on Sheet1.  The formula found by the lookup needs to refer to the info in sheet1.  Sheet1 will be duplicated 30 times with all sheets vlookuping Sheet2.
0
 

Author Comment

by:willnjen
ID: 36558512
in plain english, the formula on sheet2 needs to be...
=E1 from the current sheet & " is good."

Then when the vlookup formula on sheet one displays that formula above, the E1 gets it's value from the current sheet1.

Sorry, late in the day here in New Zealand so hope I'm being clear.

Cheers,

Will
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 41

Expert Comment

by:dlmille
ID: 36558526
I agree with teylyn, a more thorough working example (without formulas, if need be) with guidance on what you're trying to do is indeed in order.

You will undoubtedly need to create these lists of he/she's, actions (working hard, able to do stuff, etc.) and decide how you want to leverage them (re: put them all together).

Give it some thought and "paint a picture" and I'm sure teylyn, another E-E expert, or myself will be more than happy to get this over the line.  Please create several examples to get your thought across.

Cheers,

Dave
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 36558627
It appears to me that you are basically trying to return and evaluate a formula string. Although this can be done (see attached file for one way; you could also use code) to me it implies a bad workbook design. I suspect that you ought to be using a template sheet instead or something along the lines of what Dave has suggested.

Regards,
Rory
vlookup-help.xlsm
0
 
LVL 50

Expert Comment

by:teylyn
ID: 36558641
Will, I'm in New Zealand, too, so I feel the same drain pain of the day.

In your last sample you say


I want the result of the vlookup in B2 to reference E1 on this sheet.
The basic vlookup is working but the current result is looking at E1 on Sheet2.


I don't see how the "current result" of the vlookup is looking at E1 on Sheet 2 at all. There is no value in E1 on Sheet2.

In fact, the formula that I posted in my first comment will take E1 of the current sheet and combine it with the vlookup formula. Dave refined that formula to include only an exact match. The result is

=E1&VLOOKUP(A1,Sheet2!A1:B3,2,0)

Jim is good

If that's not what you want, you'll need to explain with more data and more details.

cheers, teylyn

0
 

Author Comment

by:willnjen
ID: 36558989
Hi Guys

Sorry if I'm not being clear.

See the more detailed spreadsheet attached called vlookup-help3.xlsx.

It has examples of what I wanted to achieve.

Cheers,

Will vlookup-help3.xlsx
0
 
LVL 50

Accepted Solution

by:
teylyn earned 500 total points
ID: 36559061
Hello,

In the Master sheet, replace the text with this:


StudentName is good. StudentParticiple is working well in class. StudentName is good at Excel formulas.
StudentName is average
StudentName is bad

In the Student sheets, use this as the formula in column B, starting in B1

=SUBSTITUTE(SUBSTITUTE(VLOOKUP(A1,Master!$A$1:$B$3,2),"StudentName",$E$1),"StudentParticiple",$E$2)

see attached.

cheers, teylyn
vlookup-help3.xlsx
0
 

Author Closing Comment

by:willnjen
ID: 36562758
Oooooh, now that is classy!!!  Using SUBSTITUTE makes my Master sheet much nicer and it keeps all the formula on the individual student's sheet.

Thanks so much!  It's exactly what I was trying to achieve.

Cheers,

Will
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A2 = A1 That kind of cell reference is relative.  If you copy it from A2 to B2, then B2 will get this: B2 = B1 That's all fine and good, but if you then insert a new row above row 2, you'll find: A3 = A1 B3 = B1 This is intentional. …
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now