Protecting Cell loses formatting

  • Thread starter Thread starter FP Novice
  • Start date Start date
F

FP Novice

In a lookup sheet I have made I set the cells that hold my formulas to be
locked on protection. These cells that I speak of change text color based on
the returned results from the lookup. My trouble shows up after I protect the
worksheet, once protected the cells no longer change text color based on the
returned results.

File can be provided for review.
 
Also, I am not using conditional formatting since the field can return any
one of twelve different text colors., I was thinking about defining the text
to color in VB but am not certain where to start.
 
This is what I have so far, the macro does not like the Me.Range. What should
I be using?

Private Sub Color_G6()
Dim Num As Long
Dim rng As Range
Set rng = Me.Range("G6")
On Error GoTo endit
Application.EnableEvents = False
'Determine the color
Select Case UCase(rng.Value)
Case Is = "BLUE": Num = 5 'blue
Case Is = "ORANGE": Num = 45 'orange
Case Is = "GREEN": Num = 10 'green
Case Is = "BROWN": Num = 53 'brown
Case Is = "SLATE": Num = 15 'slate
Case Is = "WHITE": Num = 1 'black
Case Is = "RED": Num = 3 'red
Case Is = "BLACK": Num = 1 'black
Case Is = "YELLOW": Num = 6 'yellow
Case Is = "VIOLET": Num = 54 'violet
Case Is = "ROSE": Num = 38 'rose
Case Is = "AQUA": Num = 42 'aqua
End Select
'Apply the color
rng.Font.ColorIndex = Num
endit:
Application.EnableEvents = True
End Sub
 
Back
Top