Find colour of a shape

tiredofit

Well-known Member
Joined
Apr 11, 2013
Messages
1,834
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
EDIT SORTED:

Code:
Dim FindColour

FindColour = ActiveSheet.Shapes("Colour Title").Fill.ForeColor.RGB
 
Last edited:
Upvote 0
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
 
Upvote 0
Thanks.

The line quoted was from a recorded macro.
 
Upvote 0

Forum statistics

Threads
1,215,040
Messages
6,122,806
Members
449,095
Latest member
m_smith_solihull

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
Back
Top