Create conflicts between items in a list using a fromula

Moe12345

New Member
Joined
Jul 14, 2021
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Hi, i am working on a project right now and need some help. To describe my problem I have horizontal list in excel with items which are user roles. Then I have a vertical list with the names of the each user. Under the horizontal list I have X matching the users each userroles based on an extract. Then also have a cell where I gather all the X's for each individual user and then also have another cell where I want to have a formula to check wether there is a conflict between the user roles. Because the idea is that a user can have multiple userroles attributed to him/her but some of these roles are conflicting with eachother and do not go together. Asuming you yourself decide which ones are allowed together which ones are not, how could you arrange this? How do I make this cell formula knowing which roles can not be together(i.e the X's). Also notice if one only 1 of the "X's" conflicts with another x then the entire Range of X's is a conlict and this should be highlighted in the "user right check cell" with a formula. This is the part where I need most help with.
Exel.png

Please feel free to ask questions If it is not clear and for additional information. Thanks in advance!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Can be done with a VBA user defined function

VBA Code:
Function ConflictCheck(Xs As Range, Conflicts As Range) As String
    Dim j As Long, ubx As Long, aConflicts, aXs, C, conflict
    aConflicts = Conflicts
    aXs = Xs
    ubx = Round(UBound(aXs, 2) / 2 + 0.1)
    For j = 1 To ubx
        If Len(aConflicts(1, j)) > 0 Then
            If aXs(1, j) = "X" Then
                C = Split(aConflicts(1, j) & "", ",")
                For Each conflict In C
                    If aXs(1, conflict) = "X" Then
                        ConflictCheck = "Conflict"
                        Exit Function
                    End If
                Next
            End If
        End If
    Next
End Function

Book2
ABCDEFGHIJKLMNOPQRSTU
1Role TableConflict Table
2
3NameRole1Role2Role3Role4Role5Role6Role7Role8Role9ConflictCheckRole1Role2Role3Role4Role5Role6Role7Role8Role9
4Person1XXXXConflict21,42,6492,7
5Person2XXXXXXConflict
6Person3XXXX 
7Person4XXXXX 
8Person5XXXXConflict
9Person6XXXXXXXConflict
10Person7XXXXX 
11Person8XXXX 
12Person9XXXConflict
13Person10XXXX 
14Person11XXXXXConflict
Sheet1
Cell Formulas
RangeFormula
K4:K14K4=ConflictCheck(B4:J4,$M$4:$U$4)
 
Upvote 0
Solution
[
Can be done with a VBA user defined function

VBA Code:
Function ConflictCheck(Xs As Range, Conflicts As Range) As String
    Dim j As Long, ubx As Long, aConflicts, aXs, C, conflict
    aConflicts = Conflicts
    aXs = Xs
    ubx = Round(UBound(aXs, 2) / 2 + 0.1)
    For j = 1 To ubx
        If Len(aConflicts(1, j)) > 0 Then
            If aXs(1, j) = "X" Then
                C = Split(aConflicts(1, j) & "", ",")
                For Each conflict In C
                    If aXs(1, conflict) = "X" Then
                        ConflictCheck = "Conflict"
                        Exit Function
                    End If
                Next
            End If
        End If
    Next
End Function

Book2
ABCDEFGHIJKLMNOPQRSTU
1Role TableConflict Table
2
3NameRole1Role2Role3Role4Role5Role6Role7Role8Role9ConflictCheckRole1Role2Role3Role4Role5Role6Role7Role8Role9
4Person1XXXXConflict21,42,6492,7
5Person2XXXXXXConflict
6Person3XXXX 
7Person4XXXXX 
8Person5XXXXConflict
9Person6XXXXXXXConflict
10Person7XXXXX 
11Person8XXXX 
12Person9XXXConflict
13Person10XXXX 
14Person11XXXXXConflict
Sheet1
Cell Formulas
RangeFormula
K4:K14K4=ConflictCheck(B4:J4,$M$4:$U$4)
Thanks, this works perfectly.
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,052
Members
448,940
Latest member
mdusw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top