I have a script that I have used for years with Excel 2000 for conditional formatting since in that version you were limited to 3 choices. On one of the computers we updated to Excel 2016 and the script no longer works. If you type a letter in a cell, for instance F or f, the script will change the color of the cell and the font color. It will also capitalize the letter, so f will be F. If I type the letter F or f in a cell now, I get the following error:
Method 'ColorIndex' of object 'Interior' failed
I know I can set up conditional formatting for many types with 2016, but then it will not work with 2000. Is there a way to fix this so it will work with both versions, or can you have it check the version you use before executing the script?
Here is the script:
Thanks,
Doc
Method 'ColorIndex' of object 'Interior' failed
I know I can set up conditional formatting for many types with 2016, but then it will not work with 2000. Is there a way to fix this so it will work with both versions, or can you have it check the version you use before executing the script?
Here is the script:
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
If Target.Column > 50 Or Target.Cells.Count > 1 Then Exit Sub
With Target.Interior
.ColorIndex = 10
Select Case UCase(Target.Value)
Case "L"
Target.Value = UCase(Target.Value)
.ColorIndex = 24
Target.Font.Color = vbBlack
Case "F"
Target.Value = UCase(Target.Value)
.ColorIndex = 41
Target.Font.Color = vbWhite
Case "H"
Target.Value = UCase(Target.Value)
.ColorIndex = 10
Target.Font.Color = vbWhite
Case "V"
Target.Value = UCase(Target.Value)
.ColorIndex = 6
Target.Font.Color = vbBlack
Case "A"
Target.Value = UCase(Target.Value)
.ColorIndex = 46
Target.Font.Color = vbWhite
Case "D"
Target.Value = UCase(Target.Value)
.ColorIndex = 17
Target.Font.Color = vbWhite
Case "X"
Target.Value = UCase(Target.Value)
.ColorIndex = 0
Target.Font.Color = vbBlack
Case Else
.ColorIndex = 0
End Select
End With
End Sub
Thanks,
Doc
Last edited by a moderator: