lovejanu4u
New Member
- Joined
- Apr 29, 2019
- Messages
- 36
Please anyone comment and provide the information.
Appreciated and thanks in advance.
Appreciated and thanks in advance.
Thanks for the information @montecarlo2012You can also create a custom function with VBA to count highlighted cells in Excel. To do that you need to create a custom function using VBA that works like a COUNTIF function and returns the number of cells for the same color.
You will follow the syntax: =CountFunction(CountColor, CountRange) and use it like other regular functions.Here CountColor is the color for which you want to count the cells. CountRange is the range in which you want to count the cells with the specified background color.
The problem is that changing a cell's color does not trigger Calculation or any VB event. If you write a UDF like this, it will have to be volatile and you will need to manually force calculation to insure that the result is current and accurate.
The other issue is where the cells get their color. If it is set by the user, then all those objections apply. If the color is set by conditional formatting, it would be better to test the format conditions rather than testing the color of the cell.