VBA Charts

Noz2k

Well-known Member
Joined
Mar 15, 2011
Messages
693
How do you set the start value of the category axis?

All I want to do is set the start value to a variable in my code (WeekSNum) and have it increment by 1 for each point on the axis.

I can't seem to get it to work. I can either get it to go from 1 to 17 which in the test I'm using is incorrect, or from 7 to 24, which is correct on the labels, but then it cuts off all plot points from 1 to 6 and doesn't have any past 17.

anyway here is my code with all the relevant bits.

Code:
Sheets("Sheet2").Shapes.AddChart.Select
    r = 1
    C = 2
    With ActiveChart
    .Parent.Name = ws2.Range("A1").Offset(Y - 1, 0)
    .Parent.Width = 800
    .Parent.Height = 400
    .ChartType = xlLine
    .SetSourceData Source:=wsm.Range("C1:C" & X)
    .SeriesCollection(1).Name = ws2.Range("C3")
    .HasTitle = True
    .ChartTitle.Text = ws2.Range("A1").Offset(Y - 1, 0)
    .Axes(xlCategory, xlPrimary).HasTitle = True
    .Axes(xlCategory, xlPrimary).AxisTitle.Text = (DF - 6) & " to " & DT
    .Axes(xlCategory).AxisBetweenCategories = False
    .Axes(xlCategory, xlPrimary).CategoryType = xlTimeScale
    .Axes(xlCategory, xlPrimary).MinimumScale = WeekSNum
     .Axes(xlCategory, xlPrimary).MaximumScale = WeekSNum + X        
.Axes(xlValue).MajorGridlines.Delete
Do Until r = 10
    .SeriesCollection.NewSeries
    .SeriesCollection(C).Values = wsm.Range("C1:C" & X).Offset(0, r)
    .SeriesCollection(C).Name = ws2.Range("C3").Offset(0, r + r)
    r = r + 1
    C = C + 1
    Loop
End With
End Sub

where WeekSNum = 7 and X = 17

Just to clarify all I want is for the first point on the X-axis to be labelled as the value for WeekSNum. I don't actually want the 7th value. Just the labelling.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Anybody have any idea? It doesn't seem like it should be something that's very difficult to do
 
Upvote 0

Forum statistics

Threads
1,224,616
Messages
6,179,912
Members
452,949
Latest member
beartooth91

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top