Solved

How to look info up on another spreadsheet file in Excel

Posted on 2011-03-24
10
208 Views
Last Modified: 2013-11-05
I need to do a price lookup from spreadsheet1 to spreadsheat2.  I need to do this via a macro because I have multiple look ups to do.  Can anyone help?


Spreadsheet1

Product A          $1.99
Product B          $2.09
Product C          $0.99

Spreadsheet2

ProductC
ProductA
ProductB
0
Comment
Question by:jrh70
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 6

Expert Comment

by:KnutsonBM
ID: 35206700
i know you said via macro, but a formula would work very well for this, vlookup is designed especially for this =vlookup(a1,'spreadsheet 1'!A:B,2,false) would do the trick

-brandon
0
 
LVL 6

Accepted Solution

by:
FernandoFernandes earned 250 total points
ID: 35206843
and if you have multiple lookups to do, you can put in the different columns, and change the third parameter, which is the column within the lookup range

=vlookup(a1,'spreadsheet 1'!A:C,3,false)
0
 

Author Comment

by:jrh70
ID: 35207723
is there a way to insert a variable while doing a vlookup?
0
 
LVL 6

Assisted Solution

by:KnutsonBM
KnutsonBM earned 250 total points
ID: 35207762
what kind of variable?  you can use an asterisk and it works well, here are a few examples,

=vlookup("*abcdefg*",'spreadsheet 1'!A:B,2,false)

this will look and see if that text is somewhere in the range

=vlookup("*"&A1&"*",'spreadsheet 1'!A:B,2,false)

this will look to see if text from a cell is somewhere in the range
0
 
LVL 6

Assisted Solution

by:KnutsonBM
KnutsonBM earned 250 total points
ID: 35207777
if you post an example of what you are working with it may make this easier to answer for you...

-brandon
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Assisted Solution

by:FernandoFernandes
FernandoFernandes earned 250 total points
ID: 35207800
you can make dynamic vlookup() by using dynamic range (using ranged name), variable to determine which column you want to return, in this case the variable would be a reference to a cell,
even the range of the vlookup could be variable too, depending on selection in a cell, which could have list validation ...

you have to tell us exactly what you want and to make it quicker and easier, upload your file if possible !

:-)
0
 
LVL 32

Expert Comment

by:Rob Henson
ID: 35240615
I notice your lookup value on sheet 2 doesn't have the space in like that on the source document. Is that just a type error in your example or is that the case in the real file?

For the lookup to work properly the lookup values have to match.

Cheers
Rob H
0
 

Author Comment

by:jrh70
ID: 35240635
yes that was a typeo.  Sorry
0
 
LVL 6

Expert Comment

by:KnutsonBM
ID: 35240651
did any of these solutions work for you?  
0
 

Author Closing Comment

by:jrh70
ID: 35240654
I got it to work with modified code of the above.
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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