Microsoft Excel Support - Mapping a Candidate to a particular Position using a Job role

Jaas Cal 0 Reputation points
2024-01-05T09:16:42.26+00:00

Hello All,

I have attached the excel sheet. Basically, we need to map a candidate to a various position and map a Position to a various candidate.

We have a list of candidates in "Candidates" sheet, we need to take a first candidate and if the "Role/Spe" in the Position sheet matches we need to get the position data (capture all columns) in the 3rd sheet "Candidates with All Positions" sheet.

So, in simple words 1 candidate may have multiple positions (based on the "Role/Spe") and we need to capture ALL the positions against that candidate. Similarly, we need to REPEAT capturing ALL the positions for ALL the candidates.

The same we need to do in reverse, we need to capture all the candidates against each and every Position (based on the "Role/Spe") in the 4th sheet "Positions with All Candidates".

Source data is "Candidates" & "Position" Sheets

Output expected in "Candidates with All Positions" & "Positions with All Candidates" sheet.

Can we have a flexibility to add more column to "Candidates" & "Position" Sheets and also to capture the added new columns in the output.

If there is no match to "Role/Spe" in "Candidate" and "Position" no need to capture any data in the output.

Pls. let me know if you need more details. I am sharing the link to download the excel file.

Download the excel file in this link ==> https://docs.google.com/spreadsheets/d/1nT_7ofssAQsek6JENQjiGBxHKN1P0bBg/edit?usp=sharing&ouid=101018147687121740410&rtpof=true&sd=true

Microsoft 365 and Office | Development | Other
Microsoft 365 and Office | Excel | For business | Windows
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Barry Schwarz 3,746 Reputation points
    2024-01-05T15:43:02.63+00:00

    You will need a macro to perform the following:

    • Sort Candidates and Position by Role/Spe
    • Create a temporary worksheet to hold intermediate results
    • In an outer loop, select the next candidate
    • -In an inner loop, find the first Position row that matches Role/Spe
      • -Add both Candidates and Position row numbers to next row in temporary worksheet
      • -Repeat inner loop until Role/Spe no longer matches
    • -Repeat outer loop until all processed
    • (at this point, temporary worksheet sorted by Candidates row number)
    • Loop through temporary worksheet by row to build Candidates with All Positions
    • -Use Candidates row number to select data to populate columns A through J
    • -Use Position row number to select data to populate columns K through AG
    • -Repeat loop until all processed
    • Sort temporary worksheet by Position row number
    • Loop through temporary worksheet to build Positions with All Candidates
    • -(processing very similar to previous loop, only the columns change)
    • Delete the temporary worksheet.
    0 comments No comments

  2. Jaas Cal 0 Reputation points
    2024-01-08T06:43:28.21+00:00

    Hi, thanks a lot for your immediate response. I tried I am sorry I could not get the desired output. Can this be done in power query? Can you pls. help me with the query please. Thanks a lot for your understanding.


  3. Jaas Cal 0 Reputation points
    2024-01-08T11:48:36.4+00:00

    Hello, No, I had not tried as you suggested. It was tough for me to understand. But I tried some other way in VBA and stuck in between. Can you please help me create the code step-by-step. Thanks for your understanding and patience.

    Private Sub Copy_Chk()
    Dim ws As Worksheet
    Set ws = ActiveSheet
    Sheets("Summary").Range("A2:AZ200000").ClearContents
        
        Sheets("Candidates").Select
        rCount = WorksheetFunction.CountA(Range("A:A")) - 1
        If rCount > 0 Then
        For i = 1 To rCount
        Range(Cells(i + 1, 1), Cells(i + 1, 10)).Select
        Selection.Copy
        Sheets("Summary").Select
        rCount = WorksheetFunction.CountA(Range("A:A"))
        If rCount > 0 Then
        Range("A" & rCount + 1).Select
        ActiveSheet.Paste
        Application.CutCopyMode = False
        Set ws = ActiveSheet
        JRS = ws.Range("C" & rCount + 1).Value
        Sheets("Positions").Select
        Set ws = ActiveSheet
        ws.Range("A1:W1").AutoFilter field:=11, Criteria1:=JRS
        ws.Range("A1").CurrentRegion.SpecialCells(xlCellTypeVisible).Copy
        Sheets("Summary").Select
        rCount = WorksheetFunction.CountA(Range("A:A"))
        If rCount > 0 Then
        Range("K" & rCount).Select
        ActiveSheet.Paste
        End If
        End If
        Next
        End If
    
    
    End Sub
    
    

  4. Barry Schwarz 3,746 Reputation points
    2024-01-30T07:35:13.9066667+00:00

    I don't know why my responses are losing all formatting and become one continuous paragraph. I hope this bullet approach solves that.

    Somehow you have managed to miss every point I was hoping to lead you to discover on your own.

    • When you use an expression of the form Range(some cell reference), the reference will resolve to the cells in the currently active worksheet. When you prefix the the expression with a worksheet specification, the reference will resolve to cells in the specified worksheet.
    • When you add a worksheet, as you do in the Set statement on line 6, that becomes the active sheet. In the subsequent code down through the two Copy statements, all your Range expressions include a sheet prefix. Therefore , these statements are not dependent on the currently active sheet.
    • Now consider what happens in your first Sort statement if you did not have the Select statement. The key1 argument is not prefixed and will therefore resolve to the current active sheet, which is scratch. That is obviously not what you want. The solution you chose is to add the Select statement. It would have been equally effective if you had added the "can" prefix to the key1 argument. Either of these solutions will cause the key1 argument to resolve to cells in the desired sheet. The discussion is the same for the second Sort statement.

    I did not ask you to remove the i loop. I did not ask you to make k the index variable of a loop. I did ask you to define k. If you did, it is not visible in your response. I also asked you to assign a particular value to k at a particular point in the program. There is no assignment statement and you have deleted the point in the program where it should have appeared.

    • Undo these changes and implement what I asked.
    • When those to changes compile successfully, look at my message from 10 January and try to implement the call to Match I described on 29 January.
    • Show your code up to this point and ask questions if needed. We can then proceed to address the issue of multiple positions for a candidate.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.