Autoshape color code tweak

rickblunt

Well-known Member
Joined
Feb 18, 2008
Messages
607
Office Version
  1. 2019
Platform
  1. Windows
Greetings,
I am using the following code to change the color in an autoshape depending on the cell value. (this is just a snippet as I am using this code to control 200+ autoshapes) and this code works very well.

HTML:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$C$46" Then
    'Change autoshape color to red depending upon cell value
  With ActiveSheet.Shapes("Rectangle 1").Fill.ForeColor
    If Target.Value <= 421 Then
        .SchemeColor = 10
        Else: .SchemeColor = 50
    End If
  End With
  ElseIf Target.Address = "$C$47" Then
    With ActiveSheet.Shapes("Rectangle 2").Fill.ForeColor
        If Target.Value <= 421 Then
            .SchemeColor = 10
        Else
            .SchemeColor = 50
        End If
    End With

I have added the following code to a command button to empty out the values in the cells that these autoshapes are linked to:


HTML:
Sub RemoveValue()
    Range("C46:C66").Select
    Selection.ClearContents
End Sub

And this works fine, I would like all of the autoshapes colors to turn back to clear or "no fill" once these values return to 0 or blank as it were. I have tried tweaking the code so that the red color is ranged from 1-421 instead of <=421 or by adding in another Else statement relecting the null value, but it isn't working - I am sure that I am just not writing the syntax properly (rookie!). Could anyone make a suggestion? Thanks
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,191,117
Messages
5,984,747
Members
439,907
Latest member
Kayfabe

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