위해 나는이표시 누락 된 값은 사용자
role user
a Joe
b Joe
c Joe
a Frank
처럼 보이는 Excel에서 테이블 그리고 두 번째 테이블
role
a
b
c
이 예처럼 각 사용자에 대해 누락 된 역할을 나열 할 수 있는가가?
Frank b c
위해 나는이표시 누락 된 값은 사용자
role user
a Joe
b Joe
c Joe
a Frank
처럼 보이는 Excel에서 테이블 그리고 두 번째 테이블
role
a
b
c
이 예처럼 각 사용자에 대해 누락 된 역할을 나열 할 수 있는가가?
Frank b c
와우. 이것은 예상보다 훨씬 어려웠습니다. 가장 우아한 솔루션은 아닙니다. user
열을 먼저 정렬해야 모든 사용자가 함께 정렬됩니다.
role
두 개 이상의 단어 XD
Sub wert()
Dim roles
Dim lastRow As Long
Dim fRow As Long
Dim user As String
Dim except As String
Dim list As String
user = Application.InputBox("which user?") 'prompt for user
With ActiveSheet
lastRow = .Cells(.Rows.count, "B").End(xlUp).Row
roles = .Range("D2:D4") 'change range as needed
With .Range("B2:B" & lastRow)
Set f = .Find(user, LookIn:=xlValues, lookat:=xlWhole) 'search for user
End With
If Not f Is Nothing Then fRow = f.Row 'if found
list = .Cells(fRow, 1)
For i = fRow To lastRow
If .Cells(i + 1, 2) = .Cells(i, 2) Or .Cells(i - 1, 2) = .Cells(i, 2) Then
list = list & .Cells(i, 1) 'add role to list
'Debug.Print list
Else
Exit For
End If
Next
For Each e In roles
If InStr(list, e) > 0 Then
Else
except = except & " " & e 'if role not found in list, then add it to string
End If
Next
.Range("F1").Value = user & ": " & except 'change range if desired
End With
End Sub
그것을하지 않을까요'b'와'Frank'에 대한 누락'c' 경우 작동하지 않습니다? –
업, 내 실수. 나는 그것을 바로 잡는다 – wert
당신은 열쇠의 역할의 주된 목록을 가지고 있느냐, 또는 단지 첫번째 역할에서 뚜렷한 역할을 빼앗을 수 있겠는가? – JNevill