Vlookup и объединение, чтобы извлечь данные из результатов опроса и показать на панели инструментов - PullRequest
0 голосов
/ 08 января 2019

enter image description here

Панель инструментов показывает имена сотрудников:

Question #1 =       Yes:[name1, name 2]   No:[name1, name2...nameX]
Question #2 =     Proficient [name1, name2 name3...nameX]   NotProficient []

Пример данных опроса в другой вкладке:

Names                   Question 1       Question 2
associate 1               Yes            Not Proficient
associate 2                No            Not Proficient
associate 3               Yes            Proficient
associate 4               Yes            Proficient
associate 5                No            Proficient

Мне нужна формула, чтобы найти ответ (да, нет), а затем посмотреть / сопоставить, кто ответил на него. Затем поместите эти имена на приборной панели в одну ячейку (раздел да или нет), разделенную символом ",".

Буду признателен за любую помощь, которую я могу получить здесь :) Благодарю вас.

Барис

1 Ответ

0 голосов
/ 08 января 2019

А как насчет решения с пользовательской функцией?

Option Explicit
Function DISPLAYRESULTS(question As Range, answers As Range, associates As Range)

    Dim finalresult As String
    Dim answerslist As Variant
    Dim cell As Range
    Dim j As Long

    ReDim answerslist(0 To 0)
    j = 0
    finalresult = question.Value & " = "

    For Each cell In answers
        If IsError(Application.Match(cell.Value, answerslist, 0)) Then
            ReDim Preserve answerslist(0 To j)
            answerslist(j) = cell.Value
            j = j + 1
        End If
    Next cell

    For j = 0 To UBound(answerslist)
        finalresult = finalresult & answerslist(j) & ":["

        For Each cell In associates
            If cell.Offset(0, answers.Column - associates.Column).Value = answerslist(j) Then
                finalresult = finalresult & cell.Value & ", "
            End If
        Next cell

        finalresult = Left(finalresult, Len(finalresult) - 2) & "] "
    Next j

    DISPLAYRESULTS = finalresult

End Function

img1

...