Bronzato
Bronzato

Reputation: 9342

Setting forecolor equal to backcolor in Excel VBA

I need to hide text inside my cells (which contains formulas). I think of setting the text color same as background color (gray). Maybe a better alternative?

enter image description here

So I record a Macro for getting the code of setting the forecolor equal to backcolor (so gray). Then I stop the macro.

enter image description here

Now I reset the forecolor to Automatic (black) then running the recorded macro again to test. The result is that my forecolor is white which is strange because it should be gray.

enter image description here

Here is the code of the macro:

With rangeToHide.Font
    .ThemeColor = xlThemeColorDark1
    .TintAndShade = -0.499984740745262
End With

Any idea why?

Upvotes: 0

Views: 484

Answers (1)

ttaaoossuu
ttaaoossuu

Reputation: 7884

Try this:

With rangeToHide
    .Font.Color = .Interior.Color
End With

Upvotes: 1

Related Questions