Find colour of a shape

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,404
This colours in a shape:

Code:
ActiveSheet.Shapes.Range(Array("Colour Title")).Select
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 255, 0)
        .Transparency = 0
        .Solid
    End With

I want to find the colour of this shape but why doesn't this work?

Code:
Dim FindColour


FindColour = ActiveSheet.Shapes.Range(Array("Colour Title")).ShapeRange.Fill.ForeColor.RGB

Thanks
 
Last edited:

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,404
EDIT SORTED:

Code:
Dim FindColour

FindColour = ActiveSheet.Shapes("Colour Title").Fill.ForeColor.RGB
 
Last edited:

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,873
Office Version
  1. 2010
Platform
  1. Windows
This colours in a shape:

Rich (BB code):
ActiveSheet.Shapes.Range(Array("Colour Title")).Select
    With Selection.ShapeRange.Fill
        .Visible = msoTrue
        .ForeColor.RGB = RGB(255, 255, 0)
        .Transparency = 0
        .Solid
    End With

I want to find the colour of this shape
I am not sure why you chose to implement the red highlighted line of code the way you did, but if I understand what you are trying to do correctly, I believe it can be written in this simpler way...
Code:
ActiveSheet.Shapes("Colour Title").Select
With that said, I would point out that you do not have to select a shape in order to do things with that shape. The following snippet of code will do the same thing your first snippet of code (shown above) does...
Code:
With ActiveSheet.Shapes("Colour Title").Fill
  .Visible = msoTrue
  .ForeColor.RGB = RGB(255, 255, 0)
  .Transparency = 0
  .Solid
End With
Now, to get the color of this shape, you can use this line of code...
Code:
FindColour = ActiveSheet.Shapes("Colour Title").Fill.ForeColor
 

Watch MrExcel Video

Forum statistics

Threads
1,127,560
Messages
5,625,507
Members
416,115
Latest member
Gonzo5711

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top