Solved

VBA: selectively hide text in themed workbook by making text same color as fill

Posted on 2015-01-27
2
55 Views
Last Modified: 2015-01-28
I'm creating a workbook from VBA and would like to hide the text in selected columns by making the text the same color as the fill in the cell. I have no problem doing this in VBA if I use standard colors but it won't work using themed colors.

I started with the old standby technique: I recorded a macro while I manually changed the text color and fill color. The result of the manual operation is exactly what I want as you'll see in cell A1 in the attached workbook. However, if you run the macro (which I've changed to operate on cell A2), you'll see the dilemma: the text is not set to the required tint to make it invisible.

Any ideas why the automated version of the manual procedure doesn't work?

BTW, setting a custom cell format of ";;;", which does hide the cell contents, won't work because I am also using filters. When I select a filter for a column containing text that was hidden using the ";;;" format, the filter doesn't see the rows that contain hidden text.
Set-font-and-fill-color-to-themed-value.
0
Comment
Question by:Scott Helmers
2 Comments
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 40574648
Hi,

pls try

    With Range("A2").Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .ThemeColor = xlThemeColorAccent4
        .TintAndShade = 0.799981688894314
        .PatternTintAndShade = 0
    End With
    Range("A2").Font.Color = Range("A2").Interior.Color

Open in new window

Regards
0
 
LVL 30

Author Closing Comment

by:Scott Helmers
ID: 40575229
Interesting, thank you.

I had tried
Range("A2").Font.ThemeColor = Range("A2").Interior.ThemeColor

Open in new window

but had not tried the .Color property instead.

Your solution works.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now