Solved

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

Posted on 2015-01-27
2
56 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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Office 2016 Excel Issue 4 26
Formula or Macro to determine variance 17 75
Dynamic Filter ? 4 21
How do I crate a Pivot table in Excel 2 10
Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

895 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