Creating graphs in VBA

N

nir020

I have used the folowing code to create a graph in VBA
Sub Macro1()

Dim c As Excel.Chart, a As Worksheet, co As ChartObjects

Set a = Worksheets("Regional Issue Graphs")
Set co = a.ChartObjects
Set c = co.Add(60, 60, 300, 300).Chart
co.Select
c.ChartWizard Source:="North", HasLegend:=False

however I am unable to write further code to which will allow me to alter
the font size of the axies of the graph I want to create, can anyone help?
 
J

Jon Peltier

Did you try the macro recorder? This is messy, but it should give you the
syntax you need:

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/2/2009 by Jon Peltier
'

'
ActiveChart.Axes(xlValue).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
ActiveChart.Axes(xlCategory).Select
Selection.TickLabels.AutoScaleFont = True
With Selection.TickLabels.Font
.Name = "Arial"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
.Background = xlAutomatic
End With
End Sub

This can be changed to the following and inserted in your original routine:

c.Axes(xlValue).TickLabels.Font.Size = 8
c.Axes(xlCategory).TickLabels.Font.Size = 8

- Jon
 

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