ColorIndex returns incorrect color

G

goss9394

Hi all

Trying to set interrior colorindex to 80% grey which I belive is #56
Yet the cell appears filled black to me and definitely changes when I
copy format from one cell to the left

Also is there a way to expand the color utility below to list what the
color palette represents
For example for value 56 col C should read "Grey 80%"

Thanks
-goss


Snippet:
With wsData
For j = i To 2 Step -1
If InStr(.Cells(j, 18), "/Tax") Then
.Cells(j, 18).EntireRow.Delete
End If
Next
Set rngHead = .Range("R1")
With rngHead
.Value = "Switch"
.Interior.Color = 56
.Font.Bold = True
.Font.ColorIndex = 2
End With
End With

Color Index Utilities
Sub ListColorIndexes()
Dim wbBook As Workbook
Dim wsColorList As Worksheet
Dim Ndx As Long

Set wbBook = ThisWorkbook
Set wsColorList = wbBook.Worksheets("ColorList")

wsColorList.UsedRange.Clear

With wsColorList
For Ndx = 1 To 56
.Cells(Ndx, 1).Interior.ColorIndex = Ndx
.Cells(Ndx, 2).Formula = clr(.Cells(Ndx, 1))
Next Ndx
End With
End Sub

Function clr(R As Range) As Integer
With R.Interior
clr = .ColorIndex
End With
End Function
 
S

Sandy

It looks like to me just scanning your code that where you try and
change the cell backround color to #56 you are using color instead of
color index try changing that line and see if it works.

Also here is a link to a function from a previous post that will return
the color description

http://www.ozgrid.com/VBA/ReturnCellColor.htm


Sandy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top