(Solved) – VBA code to change font color based on adjacent cell value and cell background

  • by
(solved)-–-vba-code-to-change-font-color-based-on-adjacent-cell-value-and-cell-background

I created a macro to collapse columns, leaving just the “Totals” column for each month.
For design purposes I have to repeat the date and the name above it in the adjacent cells left and right. For example, columns G, H, and I, have the same text, but I’m hiding the values on the sides by using the same color as the background, though they’re still there.
The problem is that when I run the macro to show only the “Total” column, I need to see those dates and the word above, and in order to do this I have to change the color of those two cells above the cell that contains the word “Total”.

I’ve been trying to code something that finds cells with the word “Total” within that row (row 10) and then changes the font color of whatever two cells are above those Total cells, but I haven’t been able to make it work. Also, when I unhide the columns, I want those fonts to match the color of the background again.

I uploaded 3 pictures so you can see a better description of what I need. Thank you very much!!!

[Photo 1][1]
[Photo 2][2]
[Photo 3][3]


[1]: https://i.stack.imgur.com/shs9O.png
[2]: https://i.stack.imgur.com/bTDcd.png

[3]: https://i.stack.imgur.com/BRc4x.png

Leave a Reply

Your email address will not be published. Required fields are marked *