Macro changes color

K

Klemen25

Hello
I have the following macro to set chart fonts to arial 10.
But If I apply this macro to a chart that already has fonts colored
differently (lets say some are red, some blue, some white) it changes
all fonts to black. I tried to remove ColorIndex hoping i would than
ignore color, but it doesn't help. How to make macro that will not
change the set colors in the chart?



Selection.AutoScaleFont = False
With Selection.Font
.Name = "Arial"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
 
D

Don Guillett

Try JUST this (untested)
sub chgfont()
With Selection.Font
.Name = "Arial"
.Size = 10
end with
end sub
 
K

Klemen25

No, this doesnt work- it does work in cells, but with chart data
labels it changes them to Arial, 10, black.
Sorry- I didnt mention before that this problem accures with data
labels? But now I tested and it changes also fonts in x or y axis from
colored to black if this macro is used.
 
D

Dave

Hi,
I suggest that you read the current ColorIndex first.
Insert this as your 2nd line of code:
A = Selection.Font.ColorIndex
Then change the 3rd to last line, .ColorIndex = A
Regards - Dave.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top