Link to home
Start Free TrialLog in
Avatar of McQMom
McQMomFlag for United States of America

asked on

Excel vba font color keeps shoeing white, instead of gray

Hi! I have code that changes the font in a column of a pivot table to a dark gray, but when I run the macro, its turns the font white. I don't know if it has "View Gridlines" turned off (which are the same dark gray color I'm trying to turn the font). Can anyone help? I'm going crazy. FontColorExample.docx  
Sub Fixfont4()
'
' Fixfont4 Macro
'

'
    Range("E4").Select
    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Formula1", xlDataAndLabel, _
        True
    Selection.Font.Italic = False
    With Selection.Font
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Forecast", xlDataAndLabel, _
        True
    With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.499984740745262
    End With
    Selection.Font.Bold = True
    Selection.Font.Italic = True
End Sub

Open in new window

Avatar of rspahitz
rspahitz
Flag of United States of America image

I suspect the problem is that the macro is applying things here:


    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Forecast", xlDataAndLabel, _
        True
    With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.499984740745262
    End With

If you take out those lines, what happens?

'    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Forecast", xlDataAndLabel, _
        True
'    With Selection.Font
'        .ThemeColor = xlThemeColorDark1
'        .TintAndShade = -0.499984740745262
'    End With
Avatar of McQMom

ASKER

Then I get all my pivot columns in regular font (Including my forecast) and my Total Shipped & Open column (A calculated item column) in bold.
Looks like it might be an anomaly in the new Excel, based on the color themes.

Restore the original code you had and add something like this just before "Selection.Font.Bold = True"


ActiveSheet.PivotTables("PivotTable1").PivotSelect "Values", xlDataAndLabel, True
    Range("F10:I12").Select
    With Selection.Font
        '.ThemeColor = xlThemeColorDark1
        '.TintAndShade = -0.499984740745262
        .Color = &H808080
        .TintAndShade = 0
    End With

Open in new window

Avatar of McQMom

ASKER

Still showing up as white. Dang - it's driving me crazy!
Post your code again so I can test it on my end.
I saw the white appear but the above code fixed it for me in v2010.
Avatar of McQMom

ASKER

I seem to be able to get it in a dark blue now, but still not in the dark gray. It still turns white...
ActiveSheet.PivotTables("PivotTable1").PivotSelect "Forecast", xlDataAndLabel, _
        True
    With Selection.Font
        .ThemeColor = xlThemeColorAccent1
        .TintAndShade = -0.249977111117893
    End With
    Selection.Font.Bold = True
    Selection.Font.Italic = True
    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Formula2", xlDataAndLabel, _
        True
    Selection.Font.Italic = True
    Selection.Font.Bold = True

Open in new window

Looks like you didn't understand that I wanted you to add my code into yours, like this:

 
Sub Fixfont4()
'
' Fixfont4 Macro
'

'
    Range("E4").Select
    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Formula1", xlDataAndLabel, _
        True
    Selection.Font.Italic = False
    With Selection.Font
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
    End With
    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Forecast", xlDataAndLabel, _
        True
    With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = -0.499984740745262
    End With

    ActiveSheet.PivotTables("PivotTable1").PivotSelect "Values", xlDataAndLabel, True
    Range("F10:I12").Select
    With Selection.Font
        '.ThemeColor = xlThemeColorDark1
        '.TintAndShade = -0.499984740745262
        .Color = &H808080
        .TintAndShade = 0
    End With
    Selection.Font.Bold = True
    Selection.Font.Italic = True
End Sub

Open in new window


However, I'm not sure that "Values" is the correct piece so you may need to adjust that to another Pivot setting.
Avatar of McQMom

ASKER

Still all just white, I think I'm just going to leave it blue - :( White-font-example.docx
Any chance of sending the workbook?
At least then I can see if the same problem happens on my end.
Avatar of McQMom

ASKER

I'll try and mutate the numbers enough to send it to you.
Avatar of McQMom

ASKER

Here it is.  Font-Color.xlsm
ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of McQMom

ASKER

Perfect! Thank you so much for your perseverance. :)