Look up Location from another sheet

nt_beans

New Member
Joined
Nov 10, 2015
Messages
26
hi, i have a workbook with two sheets (sheet1 and sheet2).
Sheet 1 has the First Name, Last Name and Location of each user.
First NameLast NameLocation
PaulAllenNew York
WhitneyCampbellChicago
AlanBarettoLos Angeles

<tbody>
</tbody>

Sheet 2 only got First Name and Last Name. There can be multiple names of same user.
I need to populate location for each user
First NameLast NameLocation
Alan Baretto
Alan Baretto
WhitneyCampbell
Alan Baretto
WhitneyCampbell

<tbody>
</tbody>

Please let me know the best way to populate location for each user in sheet2.

thanks
NT
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
concatnamerow 1
PaulAllenNew YorkPaulAllen
WhitneyCampbellChicagoWhitneyCampbell
AlanBarettoLos AngelesAlanBaretto
AlanBarettoLos Angeles#####AlanBaretto
AlanBarettoLos AngelesAlanBaretto
WhitneyCampbellChicagoWhitneyCampbell
AlanBarettoLos AngelesAlanBaretto
WhitneyCampbellChicagoWhitneyCampbell
#####
=OFFSET($G$1,MATCH(G15,$G$2:$G$4,0),-4)
the concat names are in helper column G

<colgroup><col><col><col><col span="3"><col><col span="4"></colgroup><tbody>
</tbody>
 
Upvote 0
If your interested in a macro, try
Code:
Sub Getlocation()

   Dim Cl As Range
   Dim ValU As String
   Dim Ws1 As Worksheet
   Dim Ws2 As Worksheet
   
   Set Ws1 = Sheets("sheet1")
   Set Ws2 = Sheets("sheet2")
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws1.Range("A2", Ws1.Range("A" & Rows.Count).End(xlUp))
         ValU = Cl.Value & Cl.Offset(, 1).Value
         If Not .exists(ValU) Then .Add ValU, Cl.Offset(, 2).Value
      Next Cl
      For Each Cl In Ws2.Range("A2", Ws2.Range("A" & Rows.Count).End(xlUp))
         ValU = Cl.Value & Cl.Offset(, 1).Value
         If .exists(ValU) Then Cl.Offset(, 2).Value = .Item(ValU)
      Next Cl
   End With
End Sub
 
Upvote 0
If your interested in a macro, try
Code:
Sub Getlocation()

   Dim Cl As Range
   Dim ValU As String
   Dim Ws1 As Worksheet
   Dim Ws2 As Worksheet
   
   Set Ws1 = Sheets("sheet1")
   Set Ws2 = Sheets("sheet2")
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws1.Range("A2", Ws1.Range("A" & Rows.Count).End(xlUp))
         ValU = Cl.Value & Cl.Offset(, 1).Value
         If Not .exists(ValU) Then .Add ValU, Cl.Offset(, 2).Value
      Next Cl
      For Each Cl In Ws2.Range("A2", Ws2.Range("A" & Rows.Count).End(xlUp))
         ValU = Cl.Value & Cl.Offset(, 1).Value
         If .exists(ValU) Then Cl.Offset(, 2).Value = .Item(ValU)
      Next Cl
   End With
End Sub
thanks again
 
Upvote 0
concatnamerow 1
PaulAllenNew YorkPaulAllen< < G2
WhitneyCampbellChicagoWhitneyCampbell
AlanBarettoLos AngelesAlanBaretto< < G4
col C
AlanBarettoLos Angeles#####AlanBaretto< < G15
AlanBarettoLos AngelesAlanBaretto
WhitneyCampbellChicagoWhitneyCampbell
AlanBarettoLos AngelesAlanBaretto
WhitneyCampbellChicagoWhitneyCampbell
#####
=OFFSET($G$1,MATCH(G15,$G$2:$G$4,0),-4)
the concat names are in helper column G
the minus 4 at the end sends you from col G to col C
where the locations are

<colgroup><col><col><col><col span="3"><col><col span="4"></colgroup><tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,216,473
Messages
6,130,838
Members
449,597
Latest member
buikhanhsang

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top