Lookup Name in Multiple Fields

Rcaaa

New Member
Joined
May 21, 2018
Messages
23
Hello,

I am working on a spreadsheet that has the following setup. What would be the best way to find out which projects each person is on? I was thinking of doing a vlookup, but I would like to know if there is a better alternative.

Project
Resource 1
Resource 2
Resource 3
Resource 4
1
Ana
Rob
Jim
Erica
2
Rob
Susan
Tim
Kyle

<tbody>
</tbody>

Thanks,

RCA
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
With a worksheet that looks like this

vABCDE
1ProjectResource 1Resource 2Resource 3Resource 4
21AnaRobJimErica
32RobSusanTimKyle
43AnaRobJimErica
54RobSusanTimKyle
65AnaRobJimErica
76RobSusanTimKyle

The following code will tell you on Sheet 2 which projects a person is working on when you enter this code and follow the prompts

Code:
Option Explicit


Sub projectX()
    Dim lr As Long, lc As Long, c As Range
    Dim rng As Range, lr2 As Long
    lr = Range("A" & Rows.Count).End(xlUp).Row
    lc = Cells(1, Columns.Count).End(xlToLeft).Column
    Set rng = Range(Cells(2, 1), Cells(lr, lc))
    Dim crit As String, trow As Long
    crit = InputBox("Which person to search?")
    For Each c In rng
        If c = crit Then
            trow = c.Row
            lr2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
            Range("A" & trow).Copy Sheets("Sheet2").Range("A" & lr2 + 1)    'make sure you have set up a sheet2
        End If
    Next c
End Sub
 
Upvote 0
Thanks for sharing. Would you be able to recommend a resource to learn how to create VBA coding similar to this. I would like to learn how to do it for myself.

Thanks,

RCAAA
 
Upvote 0
Check out Mr Excel's books. I used one from 2010 but I am sure he has updated them. Go to the home page for this site.
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,411
Members
448,894
Latest member
spenstar

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