This VBA macro named `RecalculateScores` performs the following tasks: ### Purpose: The...
This VBA macro named RecalculateScores
performs the following tasks:
Purpose:
The code matches mentors and mentees based on certain criteria, calculates a compatibility score for each possible mentor-mentee pair, and stores the results in an "Evaluation" worksheet.
Explanation:
-
Declaring and Initializing Variables:
- The code declares variables for worksheets (
wsMentor
,wsMentee
,wsEval
) to store references to the sheets named "Mentor Input", "Mentee Input", and "Evaluation". - Other variables are used to store the row indexes (
mentorRow
,menteeRow
,evalRow
), scoring criteria (strings likementorIndustry
, etc.), and the compatibility score (score
).
- The code declares variables for worksheets (
-
Clearing Previous Results:
- The macro clears old evaluation data in the "Evaluation" sheet by removing content from columns A to C, starting from the second row to the last populated row.
-
Looping Through Mentors and Mentees:
- The outer loop iterates through all rows in the "Mentor Input" sheet (assuming data starts from row 2).
- For each mentor, an inner loop iterates through all rows in the "Mentee Input" sheet (also starting from row 2).
-
Matching Criteria and Scoring:
- The macro retrieves the relevant pieces of data for the mentor and mentee (e.g.,
Industry
,Communication Style
,Availability
,Personality
) from specified columns. - A
score
variable starts at0
and increases by25
for each criterion (out of 4) where the mentor and mentee values match.
- The macro retrieves the relevant pieces of data for the mentor and mentee (e.g.,
-
Storing Results in the "Evaluation" Worksheet:
- For each mentor-mentee pair, the macro stores:
- Mentor's name/ID in column A,
- Mentee's name/ID in column B,
- Calculated compatibility score in column C.
- This data is placed starting at row 2 of the "Evaluation" sheet, and
evalRow
increments with each entry to keep track of the row index.
- For each mentor-mentee pair, the macro stores:
-
Output:
- After the macro completes, the "Evaluation" worksheet contains a list of all possible mentor-mentee pairs along with their scores.
- Each score reflects compatibility based on common attributes.
Summary:
This code compares all mentors and mentees from their respective sheets and assigns compatibility scores based on four specific characteristics (industry, communication style, availability, and personality). The results are neatly written to the "Evaluation" worksheet, allowing for an organized view of how well each mentor matches with each mentee. Each match is scored out of 100 (25 points per criterion).