• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

How to set the font for CategoryNames in VB?

Sometimes things that look easy are a bit hard in VB... How can I set the font for CategoryNames?? This is hard for a novice in VB.

My code (I use a radar chart):
Worksheets("Test").ChartObjects(1).Chart.Axes(xlCategory).CategoryNames = Worksheets("Test").Range("A1:A5")

...and then I need to set the font size...


Roar, Norway
0
roarbov
Asked:
roarbov
1 Solution
 
TimCotteeCommented:
Hi roarbov,

    With Worksheets("Test").ChartObjects(1).Chart.Axes(xlCategory).TickLabels.Font
        .Name = "Arial"
        .FontStyle = "Bold Italic"
        .Size = 16
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .Background = xlAutomatic
    End With

For example.

Tim Cottee MCSD, MCDBA, CPIM
http://www.timcottee.tk 

Brainbench MVP for Visual Basic
http://www.brainbench.com

Experts-Exchange Advisory Board Member
0
 
EDDYKTCommented:
For y-title


With Worksheets("Sheet1").ChartObjects(1).Chart.Axes(xlCategory).AxisTitle.Font

        .Name = "Arial"
        .FontStyle = "Italic"
        .Size = 10
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .ColorIndex = xlAutomatic
        .Background = xlAutomatic
    End With


For x-title
replace xlCategory to xlValue
0
 
roarbovAuthor Commented:
Hello.
Thanks for answering, but this TickLabels method doesn't work for my xlRadar chart - I get an error message like "cannot find this property..." on ThickLabels...!

But it helped me to find something that works..:
With Worksheets("Sheet1").ChartObjects(1).Chart.ChartGroups(1)
      .HasRadarAxisLabels = True
      .RadarAxisLabels.Font.Size = 12
End With

This is probably because its a radar chart - and I think its the same problem with pie chart, but the strange thing is that I have to set the source for this labels like this with a Axes-reference:

Worksheets("Test").ChartObjects(1).Chart.Axes(xlCategory).CategoryNames = Worksheets("Test").Range("A1:A5")

If someone can explain this problem I will accept the answer....
0
 
EDDYKTCommented:
Have you tried to use record the macro


From tool->macro-> record macro
After you've finished, press Alt-F11 to see the code
0
 
DigitalXtremeCommented:
roarbov has requested that this question be PAQ'ed and points refunded. If there are no objections to this in 72 hours I will perform this action. please post objections here.

DigitalXtreme
CS Moderator
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now