More than three conditional formatting

  • Thread starter Thread starter megaerafury
  • Start date Start date
M

megaerafury

Hi, my worksheet contains six columns, column A has a description, and
column B - F has a validation wherein users enter an "X". My problem
is:
1. Does anyone know of a script that highlights the entire row with a
certain color if an X is entered on Column B - F (different colors for
each column, and I have the color codes already).
2. Prevents users from entering two "X"s on the same row
3. Allows users to delete an "X" from a column, and clears the row of
any colors.
Hopefully someone can help me, because I've searched high and low for
this, to no avail. Thanks!
 
Hi, my worksheet contains six columns, column A has a description, and
column B - F has a validation wherein users enter an "X". My problem
is:
1. Does anyone know of a script that highlights the entire row with a
certain color if an X is entered on Column B - F (different colors for
each column, and I have the color codes already).
2. Prevents users from entering two "X"s on the same row
3. Allows users to delete an "X" from a column, and clears the row of
any colors.
Hopefully someone can help me, because I've searched high and low for
this, to no avail. Thanks!

Your best bet would be a macro, triggered either manually or via a
change event.
I'm sure there are much more efficient ways, but a start would be
along the lines of:
(note: untested)

Sub colortest()
For x = 2 To Range("A65536").End(xlUp).Row
numberofx = 0 'simple counter to confirm each row only has one X
For y = 2 To 6
If UCase(Cells(x, y).Value) = "X" Then
numberofx = numberofx + 1
Select Case y
Case 1: Cells(x, y).EntireRow.Interior.ColorIndex = 6
Case 2: Cells(x, y).EntireRow.Interior.ColorIndex = 7
'etc for each color
End Select
End If
Next
If numberofx = 0 Or numberofx > 1 Then Cells(x,
2).EntireRow.Interior.ColorIndex = xlNone
Next
End Sub
 
Back
Top