Solved

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

Posted on 2015-01-27
2
60 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

734 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