• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Get cell background color where it has a 2 color fill

arkk

New Member
Hi,

How can I try and get a cell color where it has a 2 color fill. Eg: in the attached file I have 2 colors fill green and red. How can I get the colorindex or color value? I am able to get the colorindex by

MsgBox ActiveCell.Interior.ColorIndex
for the yellow cell.
Any pointers/help even to get color 1 and color 2 separately will be appreciated.

Many Thanks.
 

Attachments

  • cell fill 2 colors.xlsx
    10.3 KB · Views: 6
Hi,

EDIT:
You can use:
Code:
Range("C2").Interior.Gradient.ColorStops(1).Color
Range("C2").Interior.Gradient.ColorStops(2).Color

This will give you 255 (RED) and 3506772 (GREEN)

As follows:
Code:
Sub GetGradientColors()

    Range("C3").Value = Range("C2").Interior.Gradient.ColorStops(1).Color
    Range("C4").Value = Range("C2").Interior.Gradient.ColorStops(2).Color
    Range("C3").Interior.Color = Range("C2").Interior.Gradient.ColorStops(1).Color
    Range("C4").Interior.Color = Range("C2").Interior.Gradient.ColorStops(2).Color

End Sub
 
Last edited:
Back
Top