Search for multiple instances of name in multiple columns and return multiple dates in a row

dtwyford

New Member
Joined
Dec 24, 2015
Messages
14
Good day.

I am seeking and very much appreciate some help.
I have a table (see below). The table contains:

Colum C-F - names of 50 people, randomly place
Colum G - a date

Column I - the names of the 50 people

Column J-M - where I want to place the results of the search.

The aim of search:
Using the name in column I, search columns C-F and find all instances. For each instance, return the corresponding date (column G) and place it in J or K or L or M.

There will be no more than 4 instances of a name in columns C-F

ABCDEFGHIJKLM
Client 1Client 2Client 3 Client 4DateClientDate1Date2Date3Date4
Person 3Person 4Person18Person 4005/01Person 1
Person 4Person7Person 2Person 3005/08Person 2
Person 8Person 5Person19Person905/15Person 3
Person 12.........05/22Person 4

<tbody>
</tbody>
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try:
Code:
Sub CopyDate()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim lColumn As Long
    lColumn = Cells(1, Columns.Count).End(xlToLeft).Column
    Dim person As Range
    Dim foundPerson As Range
    Dim sAddr As String
    For Each person In Range("I2:I" & LastRow)
        Set foundPerson = Range("C2:F" & LastRow).Find(person, LookIn:=xlValues, lookat:=xlWhole)
        If Not foundPerson Is Nothing Then
            sAddr = foundPerson.Address
            Do
                lColumn = Cells(person.Row, Columns.Count).End(xlToLeft).Column + 1
                Cells(person.Row, lColumn) = Cells(foundPerson.Row, 7)
                Set foundPerson = Range("C2:F" & LastRow).FindNext(foundPerson)
            Loop While foundPerson.Address <> sAddr
            sAddr = ""
        End If
    Next person
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Mumps.
Thank you! This will definitely be a keeper. Worked like a charm. Thank you again.
 
Last edited:
Upvote 0
Hi!

Another way (with formula):

In J2 and copy down and to the right

Array Formula - Use Ctrl+Shift+Enter to enter the formula

=IFERROR(SMALL(IF($C$2:$F$5=$I2,$G$2:$G$5),COLUMNS($J2:J2)),"")


ABCDEFGHIJKLMN
1Client 1Client 2Client 3Client 4DateClientDate1Date2Date3Date4
2Person 3Person 4Person18Person 4001/05/2018Person 108/05/201822/05/2018
3Person 1Person 2Person 3Person 408/05/2018Person 208/05/201822/05/2018
4Person 8Person 5Person19Person915/05/2018Person 301/05/201808/05/201822/05/2018
5Person 12Person 1Person 2Person 322/05/2018Person 401/05/201808/05/2018
6
***************************************************************************************************************

<tbody>
</tbody>


Markmzz
 
Upvote 0

Forum statistics

Threads
1,215,398
Messages
6,124,693
Members
449,179
Latest member
kfhw720

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