sum & count colored cells automatically when colored cells change

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,448
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hello
i have data in sheet1 and ih ave two function one to sum colored cells and the other count colored cells and i have code in event worksheets change it color the cells based on conditions all of them works but the problem when change color from a2:e it doesn't change automatically when sum and count colored in column h, i i have to press any cell and move another cell then happens changes , i would directly change color cell it changes the values in column h,i
this is my code in worksheets change event
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub 'check for range
    If Target.Value = "10" Then 'check if yes
        Target.Offset(0, 1).Interior.ColorIndex = 6
    ElseIf Target.Value = "15" Then 'check if no
        Target.Offset(0, 1).Interior.ColorIndex = 3
        Target.Offset(0, 2).Interior.ColorIndex = 5
    Else
        Target.Offset(0, 1).Interior.ColorIndex = xlNone
    End If
End Sub

1.JPG
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.

Forum statistics

Threads
1,217,004
Messages
6,133,976
Members
449,850
Latest member
ali_jellybean

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