Conditional Formatting Problem - Highlight if multiple of select cells are populated

grreyes24

New Member
Joined
Jun 22, 2015
Messages
13
Office Version
  1. 365
Platform
  1. Windows
Attached is a picture showing what I'm trying to accomplish but I'm not quite getting it.

first column has 20 roles listed down the rows. 5 of them are "conflicting" A2, A7, A12, A16, and A20 (I highlighted these in yellow, but not needed on the formatting). A user can select none or any one of these roles, but not two or more. If the user does select multiple of these roles, I would like to highlight the conflicting cells (red on sample).

So it's not just that the cell is populated, but that other particular cells are populated as well.
 

Attachments

  • Conflicting Roles Mock.jpg
    Conflicting Roles Mock.jpg
    60.8 KB · Views: 7

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Would you change your profile, please, to indicate what version of Excel you run and post your example using XL2BB ?!
 
Upvote 0
Off the top of my head I couldn't think of a formula to handle this but came up with this:

Code:
Sub highlgt()
Dim str1 As String, ary() As String, i As Long
Dim icol As Long, icol2 As Long

For icol = 2 To 5
icol2 = icol - 1
str1 = ""
If Cells(3, icol) = "x" Then
 str1 = str1 & WorksheetFunction.Choose(icol2, "B", "C", "D", "E", "F") & "3 "
 Else
 End If
If Cells(8, icol) = "x" Then
 str1 = str1 & WorksheetFunction.Choose(icol2, "B", "C", "D", "E", "F") & "8 "
 Else
 End If
If Cells(13, icol) = "x" Then
 str1 = str1 & WorksheetFunction.Choose(icol2, "B", "C", "D", "E", "F") & "13 "
 Else
 End If
If Cells(17, icol) = "x" Then
 str1 = str1 & WorksheetFunction.Choose(icol2, "B", "C", "D", "E", "F") & "17 "
 Else
 End If
If Cells(21, icol) = "x" Then
 str1 = str1 & WorksheetFunction.Choose(icol2, "B", "C", "D", "E", "F") & "21 "
 Else
End If

ary = Split(str1)
If 1 < UBound(ary) Then
For i = 0 To UBound(ary) - 1
Range(ary(i)).Interior.ColorIndex = 19
Next i
Else
End If
Next icol
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,830
Members
449,096
Latest member
Erald

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