Sub PerformanceGrid()
Dim rngMgrInput As Range
Dim rngGrid As Range
Dim saEmployee() As String
Dim lRecordNum As Long
Dim vResults As Variant
Dim vCapability As Variant
Dim lResCounter As Long
Dim lCapCounter As Long
Dim rngCell As Range
Dim lHeight As Long
'Build two arrays to hold the options for Results and Capability
vResults = Array("Consistently/Sustainable Exceeded", "Partially Exceeded", "Achieved", "Partially Achieved", "Not Achieved")
vCapability = Array("Unsatisfactory", "Blank1", "Needs Improvement", "Blank2", "Meets Expectations", "Blank3", "Exceeds Expectations", "Blank4", "Excellent", "Blank5")
'Get the Input and output ranges
Set rngMgrInput = ThisWorkbook.Worksheets("Manager Input").UsedRange
Set rngGrid = ThisWorkbook.Worksheets("Performance Grid").Range("B7:K11")
'Resize the employee array to hold 3 pieces of data for each employee Name, Results and Capability
ReDim saEmployee(1 To 3, 1 To rngMgrInput.Rows.Count - 2)
'Loop through the input table, adding each employee, their result, and capability
For lRecordNum = 1 To rngMgrInput.Rows.Count - 2
saEmployee(1, lRecordNum) = rngMgrInput.Cells(2 + lRecordNum, 1)
saEmployee(2, lRecordNum) = rngMgrInput.Cells(2 + lRecordNum, 6)
saEmployee(3, lRecordNum) = rngMgrInput.Cells(2 + lRecordNum, 11)
Next lRecordNum
'Clear the output grid
rngGrid.ClearContents
'Loop through each record in the Employee array
For lRecordNum = 1 To UBound(saEmployee, 2)
'Loop through each record in the Results array
For lResCounter = LBound(vResults) To UBound(vResults)
'Loop through each record in the Capability array
For lCapCounter = LBound(vCapability) To UBound(vCapability)
'If the current employee has both the current Results
'and Capability value then add them to that cell in the grid
If saEmployee(2, lRecordNum) = vResults(lResCounter) _
And saEmployee(3, lRecordNum) = vCapability(lCapCounter) Then
'Determine which cell in the grid the employee belongs to, if the row height is above 350, switch to the next cell over
Set rngCell = rngGrid.Cells(1 + lResCounter, 1 + lCapCounter)
With rngCell
If .RowHeight > 350 Then
With .Offset(0, 1)
If .Value = "" Then
.Value = saEmployee(1, lRecordNum)
Else
.Value = .Value & Chr(10) & saEmployee(1, lRecordNum)
End If
End With
Else
.Value = .Value & Chr(10) & saEmployee(1, lRecordNum)
End If
End With
End If
'run the "fitnicely" macro
Application.Run "FitNicely"
Next lCapCounter
Next lResCounter
Next lRecordNum
Sheets("Performance Grid").Select
'Application.Run "CompensationGrid"
End Sub