[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Excel macro: merge data

Posted on 2011-05-12
4
Medium Priority
?
314 Views
Last Modified: 2012-05-11
Hi Experts,

Data from 2 sheets need to be merged.
Values from sheet1 column E need looked up in sheet2 column A.
If found the corresponding value of sheet2 column B needs copied to sheet1 column D.

 sheet1
 sheet2

 result
The  xls file with sample data is attached.

Thanks a lot!

example.xls
0
Comment
Question by:Watnog
  • 2
4 Comments
 
LVL 24

Assisted Solution

by:StephenJR
StephenJR earned 400 total points
ID: 35746147
Try this in D2 and copied down:

=INDEX(Sheet2!$B$2:$B$10,MATCH(E2,Sheet2!$A$2:$A$10,0))
0
 
LVL 4

Accepted Solution

by:
petr_hlucin earned 1600 total points
ID: 35746148
Hi,

use VLOOKUP function. For the first row in the example table it is:
=VLOOKUP(E2;Sheet2!A:B;2)

Attached is the example XLS file with solution.
example.xls
0
 
LVL 24

Expert Comment

by:StephenJR
ID: 35746157
Or if you wanted to have a blank rather than error message:

=IF(ISNUMBER(MATCH(E2,Sheet2!$A$2:$A$10,0)),INDEX(Sheet2!$B$2:$B$10,MATCH(E2,Sheet2!$A$2:$A$10,0)),"")
0
 

Author Comment

by:Watnog
ID: 35746414
Thank you both.
The vlookup does a great job.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

873 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