PDA

View Full Version : sum only red fonts



Borut
11-25-2020, 03:42 AM
I have macro to merge 4 number for 1 worker. I have 82 workers in the worksheet.
So, 1 worker have 4 diferent numbers.
For this 4 numbers ( in 4 columns), 2 numbers are red (1 to all 4)

1. I sum all numbers with sum function- is ok
2. How I sum only red numbers font color vbred? for all 82 workers(2 rows)?

p45cal
11-25-2020, 09:47 AM
User defined function:
Function SumRed(rangeToSum)
For Each cll In rangeToSum.Cells
If cll.Font.Color = vbRed Then SR = SR + cll.Value
Next cll
SumRed = SR
End Function
Use on sheet:
=SumRed(E5:G10)

Borut
11-25-2020, 11:52 PM
I copy to modul.
on sheet copy formula, but give me false name.
why?

p45cal
11-26-2020, 05:48 AM
Works here:
27503

SamT
11-26-2020, 01:02 PM
Conditional Formatting in use?

Borut
12-08-2020, 11:02 AM
found and repair my mistake