
Thanks for posting your question in the Microsoft Q&A forum.
Here is an example VBA function that counts the number of cells with a specific colour:
https://trumpexcel.com/count-colored-cells-in-excel/
** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful **