You are here:

Excel/VLookup on Multiple sheets, returning adjacent cell on same matched row

Advertisement


Question
my workbook contains 2 sheets:

Sheet 1:
Column A = Object name
Column AC = Matched objects
Column AD = ?

Sheet 2:
Column A = Object name
Column Z = Module Type

---

I have matched the like object names in column AC on Sheet 1 using =IF(ISNA(VLOOKUP(TRIM(A2),'Sheet2'!$A:$A,1,FALSE)),"not in Tranches 1, 2, 3 or 4","Match")


For the "matches" I now need to also bring back the module associated with the matched object and put that value into column AD in Sheet 1. (I need to put all the data on Sheet 1 because Sheet 1 also has more information that is needed for my task.)

How do i bring back information for the matches in column AD on Sheet 1?

Answer
Hi Russell,

If I understand your question correctly, if a match is found in the lookup you would like to then essentially repeat the lookup returning the value in column Z of the same row.  It is also desirable to do this without the inefficiency of repeating the lookup in order to get the value in column Z.

One way to do this is to use MATCH to do the lookup rather than VLOOKUP.  MATCH returns the row that the match occurs in, so it can be used with the INDEX function to directly get the desired value in that row.  This also enables one to look up multiple items, and even to return items from adjacent cells or rows, without having to repeat the lookup.

In your case the way this would work would be to pick another column in Sheet1 to do the MATCH in--you could even hide this column.  You could use this formula:

=MATCH(TRIM(A2),Sheet2!$A:$A,0)

This will give the row number where the match is found, or #N/A if no match.  Let's just say for example that this column is AE.  Now the formula you currently have could be simplified to:

=IF(ISNA(AE2),"not in Tranches 1, 2, 3 or 4","Match")

and the formula in AD for the associated module would be:

=INDEX(Sheet2!$Z:$Z,AE2)

Using the row number from AE2 to get the value from that row in column Z.

Feel free to follow up if I have misinterpreted your question in any way.

Damon
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Damon Ostrander

Expertise

I have extensive experience with VBA programming in Excel 5 through Excel 2013. As a former aerospace engineer with a large aerospace corporation and consultant in a small defense technology services company, I have developed a wide range of applications in VBA, including simulations involving mixed-language programming, satellite orbit mechanics, graphics and animation, and real-time applications. I am interested in moderate to hard VBA-related questions only.

Experience

I have developed and taught several courses in Excel VBA programming and also VBA programming in Office 97, 2000, and 2007. I have developed a number of large technical applications in Excel VBA for use within the aerospace industry.

Education/Credentials
B.S. in Electrical Engineering and Computer Science, University of California, Berkeley.

©2016 About.com. All rights reserved.