VBA not updating when cell value changes

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
676
Office Version
  1. 2016
Platform
  1. Windows
Hi,

I have some code in my worksheet (entered by right clicking wksheet tab and entering code) as follows...

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$E$8" Then
Select Case Target.Value
Case Is = "Full"
ActiveSheet.Shapes("Rectangle 1").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 118, 115)
Case Is = "Empty"
ActiveSheet.Shapes("Rectangle 1").Select
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 158, 154)

But when I copy & paste a new value into my target cell ($E$8), the vba doesn't detect the change and update Rectangle 1's colour...

Any ideas on how I can automate this?

Many thanks,
Chris
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Try:
Code:
Option Compare Text
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$E$8" Then
        Select Case Target.Value
            Case "Full"
                ActiveSheet.Shapes("Rectangle 1").Select
                Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 118, 115)
            Case "Empty"
                ActiveSheet.Shapes("Rectangle 1").Select
                Selection.ShapeRange.Fill.ForeColor.RGB = RGB(0, 158, 154)
        End Select
    End If
End Sub
 
Upvote 0
Hi,

Have tried that and it didn't seem to work?

Rgds
 
Upvote 0

Forum statistics

Threads
1,196,506
Messages
6,015,595
Members
441,904
Latest member
edris Alsatouf

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