List of Required Positions Auto-Filled with Matching List without Duplicating

jamiers

New Member
Joined
May 20, 2007
Messages
15
Hi All,

I have a strange request. I have attached this workbook of sample data.
qualnames.xlsx

Sheet 1 has a list of required positions.
Sheet 2 has a list of all the people that are qualified for a position listed on Sheet 1.

How can I have Excel fill names into sheet 1 column B from Sheet 2 if they match the required position.... AND the big one... don't duplicate the name anywhere on Sheet 1?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
See if this does what you want.
VBA Code:
Sub FillPositions()
    Application.ScreenUpdating = False
    Dim srcWS As Worksheet, desWS As Worksheet, v1 As Variant, i As Long, fnd As Range, sAddr As String
    Set srcWS = Sheets("She")
    Set desWS = Sheets("Sheet1")
    v = desWS.Range("A2", desWS.Range("A" & Rows.Count).End(xlUp)).Value
    For i = LBound(v) To UBound(v)
        Set fnd = srcWS.Range("B:B").Find(v(i, 1), LookIn:=xlValues, lookat:=xlWhole)
        If Not fnd Is Nothing Then
            sAddr = fnd.Address
            Do
                If fnd.Offset(, 1) <> "x" And WorksheetFunction.CountIf(desWS.Range("B:B"), fnd.Offset(, -1)) = 0 Then
                    desWS.Range("B" & i + 1) = fnd.Offset(, -1)
                    fnd.Offset(, 1) = "x"
                    Exit Do
                Else
                    Set fnd = srcWS.Range("B:B").FindNext(fnd)
                    If fnd.Offset(, 1) <> "x" And WorksheetFunction.CountIf(desWS.Range("B:B"), fnd.Offset(, -1)) = 0 Then
                        desWS.Range("B" & i + 1) = fnd.Offset(, -1)
                        fnd.Offset(, 1) = "x"
                        Exit Do
                    End If
                End If
            Loop While fnd.Address <> sAddr
            sAddr = ""
        End If
    Next i
    srcWS.Columns("C:C").ClearContents
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,120
Members
451,399
Latest member
alchavar

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