Find colour of a shape

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,414
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:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,414
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,981
Office Version
  1. 2016
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,130,138
Messages
5,640,335
Members
417,139
Latest member
madcabbie

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