sum & count colored cells automatically when colored cells change

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,439
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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Forum statistics

Threads
1,216,375
Messages
6,130,245
Members
449,568
Latest member
mwl_y

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