Here is the code that is supposed to compare these five names: Robert, Greg, Terri, David, Julie (Rows 2 through 6 in column A). Then compare these categories (top row column B through X): 1:1 Conf Calls, Accident/Injury Follow-up, Attend Required Training, Budget...etc (23 categories in total of tasks these people spent their time on for a number of months). Based on the results of those two comparisons, the spreadsheet is supposed to upload the amount of hours into the correct row and category column for that person.
Public Function AddValue(NameItem As Variant, CatItem As Variant, lngScore As Long) As Boolean
Dim lngRow As Long
Dim lngColumn As Long
Dim lngTargetRow As Long
Dim lngTargetColumn As Long
lngTargetRow = 0
lngTargetColumn = 0
For lngRow = 2 To 6
If Sheet6.Cells(lngRow, 2) = NameItem Then
lngTargetRow = lngRow
End If
Next lngRow
For lngColumn = 2 To 24
If Sheet6.Cells(lngColumn, 2) = CatItem Then
lngTargetColumn = lngColumn
End If
Next lngColumn
If lngTargetRow <> 0 And lngTargetColumn <> 0 Then
Sheet6.Cells(lngTargetRow, lngTargetColumn) = Sheet6.Cells(lngTargetRow, lngTargetColumn) + lngScore
AddValue = True
ElseIf lngTargetRow <> 0 Then
Sheet6.Cells(lngTargetRow, lngColumn) = Sheet6.Cells(lngTargetRow, lngColumn) + lngScore
AddValue = True
ElseIf lngTargetColumn <> 0 Then
Sheet6.Cells(lngRow, lngTargetColumn) = Sheet6.Cells(lngRow, lngTargetColumn) + lngScore
AddValue = True
Else
Sheet6.Cells(lngRow, lngColumn) = Sheet6.Cells(lngRow, lngColumn) + lngScore
AddValue = False
End If
End Function