This VBA code defines a subroutine named `RecalculateScores`, which is...
This VBA code defines a subroutine named RecalculateScores
, which is designed to calculate compatibility scores between mentors and mentees based on specific criteria. Here's a detailed explanation of the code's functionality:
-
Overview:
- This program compares data from two worksheets, "Mentor Input" and "Mentee Input," and writes the matching scores to a third worksheet called "Evaluation."
- Each mentor-mentee pair is evaluated against several compatibility metrics, and a score is calculated based on weighted contributions of different matching aspects.
-
Data Setup:
wsMentor
,wsMentee
, andwsEval
are worksheet objects initialized to represent the "Mentor Input," "Mentee Input," and "Evaluation" sheets within the current workbook.- The procedure also defines variables to represent the rows and specific fields for mentors and mentees, as well as weights for various matching dimensions.
Weights Used:
- Industry match: 30% (0.3)
- Skills vs. Goals match: 30% (0.3)
- Communication style match: 15% (0.15)
- Availability match: 15% (0.15)
- Personality trait match: 10% (0.1)
-
Clearing Existing Data:
- Before recalculating the scores, the code clears old evaluation data from rows 2 to the last used row in the "Evaluation" worksheet.
-
Iterating Over Mentors and Mentees:
- For each mentor (starting from row 2 in the "Mentor Input" sheet), the program goes through all mentees (starting from row 2 in the "Mentee Input" sheet).
- The relevant data for each mentor and mentee is read into variables (industry, communication style, availability, skills/goals, personality).
-
Scoring Logic:
- Compatibility is calculated based on the following matches:
- Industry Match: Compares mentor and mentee industries.
- Skills vs Goals Match: Checks if any of the mentor's skills (split by commas) match the mentee's goals.
- Communication Style Match: Compares communication preferences of mentor and mentee.
- Availability Match: Compares availability preferences.
- Personality Match: Compares personalities.
- A score is incrementally updated based on weighted contributions from each dimension.
- Compatibility is calculated based on the following matches:
-
Storing Results:
- For each mentor-mentee pair, the results are written to the "Evaluation" sheet:
- Column A: Mentor name (from column 1 of "Mentor Input").
- Column B: Mentee name (from column 1 of "Mentee Input").
- Column C: Compatibility score as a percentage (rounded to the nearest whole number).
Each evaluation result is written row-by-row, incrementally.
- For each mentor-mentee pair, the results are written to the "Evaluation" sheet:
-
How Scores Are Calculated:
- If all attributes match perfectly, the maximum possible score is 100%.
- Partial matches reduce the score based on the weights assigned to each dimension.
Purpose of the Code:
This program is essentially a mentor-mentee matching algorithm designed for situations where you want to pair mentors with mentees based on compatibility in multiple aspects such as industry, skills, communication, availability, and personality. The output is a scored evaluation of each possible mentor-mentee pairing, saved in the "Evaluation" sheet.