Set the fill color of a shape

I want to set the fill colour of a shape using HEX so I have

selCellColour=ActiveCell.DisplayFormat.Interior.Color

To get the colour of the cell and want to use

ActiveSheet.Shapes("Test").Fill.ForeColor = Hex(selCellColour)

But I keep getting the a Type Mismatch error message. How can I resolve this, I don't want to colour to RGB I want to use the HEX value.

3

1 Answer

The ForeColor property of a Shape's Fill is of type ColorFormat. ColorFormat can only be assigned an RGB or a color in the color scheme.

Per the ColorFormat page:

You can set colors to an explicit red-green-blue value (by using the RGB property) or to a color in the color scheme (by using the SchemeColor property).

So, if you don't prefer RGB, you could explore the color scheme method.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like