Sort List/Group, if matches value then return a value.

jmcgillis14

New Member
Joined
Sep 24, 2014
Messages
12
ABCD
1
NameNumberNameNumber
2Alex15
Sarah45
3Eric20Steve33
4Steve33
5Seth33
6Sarah45
7Erica50

<tbody>
</tbody>

I need to be able to Search Column A, find a Match for column C. Once that Matches, I need to Fill Column D with the same number to the right of the cell that matches. For example, if I type in Sarah in C4, I need D4 to bring me back 45. If I typed Alex into C3, D3 needs to return 15.

Thank you for your help.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Unless you've skipped an important criteria, this appears to be a straight-forward VLOOKUP.

Code:
=VLOOKUP(C2,$A$1:$B$7,2,FALSE)

Fill down.
 
Upvote 0
Here is a VBA solution

Code:
Option Explicit


Sub SarahSteve()
    Dim lrA As Long, lrC As Long, i As Long, j As Long
    Application.ScreenUpdating = False
    lrA = Range("A" & Rows.Count).End(xlUp).Row
    lrC = Range("C" & Rows.Count).End(xlUp).Row
    For i = 2 To lrC
        For j = 2 To lrA
            If Range("C" & i) = Range("A" & j) Then
                Range("D" & i) = Range("B" & j)
            End If
        Next j
    Next i
    Application.ScreenUpdating = True
    MsgBox "Completed"
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,926
Messages
6,122,306
Members
449,079
Latest member
juggernaut24

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