bullfrog97
bullfrog97

Reputation: 53

Excel - How to change a shape color based of the color of another cell

I am trying to change the color of multiple shapes based off a table on another tab. The table contains part, quadrant, shape name, and value (cell with specific color.) I am trying to tie the shape to the color by using shape name and range of where the color cell is but I get a sub/function not defined. The colors for the values in the table is based off a conditional format.

Sub Update()

Dim CellColor As Long
Dim ShapeColor As Variant

    CellColor = Worksheets("Sheet1").Range("D2").DisplayFormat.Interior.Color
    ShapeColor = Worksheets("Sheet1").Range("C2").Value
    Worksheets("main").Shapes(ShapeColor).Fill.ForeColor.RGB = CellColor

    Worksheets("main").Select
End Sub

enter image description here

enter image description here

Upvotes: 0

Views: 731

Answers (1)

BigBen
BigBen

Reputation: 50008

Moving my comments to an answer:

  • Set should not be used here. Worksheet("main") is missing an s - Worksheets.
  • If conditional formatting, then you need to work with Worksheets("Sheet1").Range("D2").DisplayFormat.Interior.Color.

Upvotes: 1

Related Questions