Excel - A macro to fill in data automatically

Ask a question


I have two worksheets in Excel 2007 and am trying to automatically fill in cells in the 2nd worksheet two based on values in the first worksheet. Both worksheets contain name, last name, address, phone number (no unique identifiers though). Some of these contact details are repeated in worksheet2. Whenever an identical name (first name, last name) is typed into the second worksheet, I would like the contact details fields in worksheet 2(address, phone number, etc) to be filled automatically. Could anyone help with the code?


Here a small sample of the code:

sheet 1 contains data from A1 to D5  

first name last name address phone no.  
a s sssss 123  
a d ddddd 234  
s d ffffffff 345  
f g gggggg 678  

sheet 2 contains data from A1 to B3  

first name last name  
a d  
f g  

in the second sheet in C2 copy this formula  


copy C2 down and to right.  

you get the results like this  

first name last name address phoneno.  
a d ddddd 678  
f g gggggg 678 

Note that

Solved by venkat1926
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team