Using “macros” for this kind of task is a bad idea. It may be encouraged by MS because they know that this helps to reinforce the incompatibility with free software. OK I sometimes am told that VBA is rather time-efficient. LibO API/BASIC may not be to the same degree.
The appropriate means for the task as I read it is Conditional Formatting (CF). See the answer and example by @Vitaly . Within reason you can also define different colors controlled by more than one condition. If needing extensive calculations based on MATCH or some variant of lookup e.g. CF will be significantly more efficient than any solution based on “macros”, but also than a solution applying the STYLE() function.
The reason is that CF conditions are evaluated (on the fly) only for cells inside the view, while cell formulas are evaluated under the rule of a recalculation queue which will at least include every cell of any sheet which is in any way - direct or indirect- referenced by any formula inside the view.
If you intend to retrieve the results of conditions via the format, CF cannot help. In this case it is anyway the only recommendable design to calculate these results in dedicated helper cells. Information explicitly needed must be explicitly accessible.
(No. I’m not a developer and I did not analyse the C++ code. I tested a lot in the field, however.)