Solved

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

Posted on 2015-01-27
2
59 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 50

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

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…

756 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