|
-
Mar 29th, 2007, 04:28 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Another Chart Problem
Hey All,
I have a function which creates charts from a specified range (always the "A" column of months, and one of many other columns). I allow only part of the entire column to be graphed (any part from 1-30 or 10-25), or the entire thing if the user so desires. This is all working great, except that the x-axis is not labeled correctly. For example if I only wanted to graph from months 4-10, the chart does correctly display the data for these months, except that the x-axis is labeled from 1-7 instead of 4-10. Anything I can do to force the graph to label the axis with this format instead of just always starting at 1? Here's my code if that is of help. Thanks much
Code:
If chkVolume.Value = True Then
Dim chartVolume As Chart
rangeName = "a" & startMonth & ":a" & endMonth & ", " 'Reset
rangeName = rangeName & "j" & startMonth & ":j" & endMonth
Call AddChartSheet("NNH3 Volume", rangeName, "LBS / AC N", graphStyle, chartVolume)
End If
End Sub
Sub AddChartSheet(chartName As String, setRange As String, yTitle As String, graphStyle As Integer, chartOf As Chart)
Set chartOf = Charts.Add
For Each shtNext In Sheets
If shtNext.Name = chartName Then 'Search/Delete charts w/ same name
Application.DisplayAlerts = False 'No delete prompt
Sheets(chartName).Delete
Application.DisplayAlerts = True
End If
Next shtNext
With chartOf
.Name = chartName
If graphStyle = 2 Then
.ChartType = xlColumnClustered
ElseIf graphStyle = 1 Then
.ChartType = xlLine
End If
.SetSourceData Source:=Sheets("SOILSYM_MONTH").Range(setRange), _
PlotBy:=xlColumns
.HasTitle = True
.ChartTitle.Text = chartName
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Month"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = yTitle
.SeriesCollection(1).Delete
.HasLegend = False
End With
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|