Change cell text format based on background colour

cadewhitbourn

New Member
Joined
Oct 22, 2018
Messages
1
I would like to change the text colour used for formatting a cell based on the background colour of the current cell
i.e. I want to set the text colour to be the same as the background colour, essentially making the text in the cell invisible.

So whatever the background colour for a given range, set the text colour to be the same.

Ideally I'd like to be able to turn this macro on/off.

I am using Excel as a GANT chart and I'm maintaining a reference number in each cell that I don't want to be visible to other users, but I need to be able to easily maintain.

Any help?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
This VBA assumes that the range you select (highlight) will all have the same background color.

Code:
Option Explicit


Sub ColorMe()
    Dim c As Range, x As Long
    Set c = Selection
    x = c.Interior.ColorIndex
    c.Font.ColorIndex = x
End Sub

To revert a range selected back to black print
Code:
Option Explicit


Sub UncolorMe()
    Dim c As Range, x As Long
    Set c = Selection
    c.Font.ColorIndex = 1
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top