Autoshape color code help

rickblunt

Well-known Member
Joined
Feb 18, 2008
Messages
609
Office Version
  1. 2019
Platform
  1. Windows
Greetings,

I am trying to use the following code to change the color of an autoshape depending upon the value in a cell that it is hyperlinked to. (Rectangle1 is hyperlinked to cell "C46") So if I click on Rectangle1, the cursor is moved to C46, where I type in my value. If the value is less than 601, I need rectangle1 to turn red. Right now nothing happens at all, no errors or anything.


HTML:
With Worksheets("Inspection Sheet")
        'Change autoshape color to red depending upon cell value
        If .Range("C46").Value <= 600 Then
            ActiveSheet.Shapes("Rectangle1").Fill.ForeColor.SchemeColor = 10
 
        End If
    End With

Thanks for the help, I am still pretty much a noob, there is so much to learn...
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
If you want to automate it, right click the sheet's tab, View Code, and paste:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  If Target.Address <> "$C$46" Then Exit Sub
    'Change autoshape color to red depending upon cell value
  With ActiveSheet.Shapes("Rectangle 1").Fill.ForeColor
    If Target.Value <= 600 Then
        .SchemeColor = 10
        Else: .SchemeColor = 1
    End If
  End With
End Sub

Notice that I changed the name of your shape to the default name for the first one.
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,605
Members
449,038
Latest member
Arbind kumar

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