So I have a workbook setup where the user inputs a date range, clicks a button and it looks through sheets for the specified range and calculates the sum or average where appropriate and puts the calculated values into a table on a summary sheet.
The sheets that are searched through are all labelled Week1 through to Week52, using X variable to determine the number.
On the summary sheet I have a chart which is used to show the trend over the time period. However the problem I have is that I want the X-axis (the category axis) to begin with the number of the first week in the range, at the moment it begins with number 1.
If the range is Week7 to Week10 I would want the x-axis to read 7, 8, 9, 10. Rather than 1, 2, 3, 4.
Anyway here is my code for the chart at the moment
Any help would be greatly appreciated, have searched a lot on google but can't seem to find an answer as to how to set the first value of the x-axis
The sheets that are searched through are all labelled Week1 through to Week52, using X variable to determine the number.
On the summary sheet I have a chart which is used to show the trend over the time period. However the problem I have is that I want the X-axis (the category axis) to begin with the number of the first week in the range, at the moment it begins with number 1.
If the range is Week7 to Week10 I would want the x-axis to read 7, 8, 9, 10. Rather than 1, 2, 3, 4.
Anyway here is my code for the chart at the moment
Code:
Sheets("Sheet2").Shapes.AddChart.Select
r = 2
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(xlValue).MajorGridlines.Delete
If ws2.Range("W3").EntireColumn.Hidden = True Then
Do Until r = 20
.SeriesCollection.NewSeries
.SeriesCollection(C).Values = wsm.Range("C1:C" & X).Offset(0, r)
.SeriesCollection(C).Name = ws2.Range("C3").Offset(0, r)
r = r + 2
C = C + 1
Loop
ElseIf ws2.Range("Y3").EntireColumn.Hidden = True Then
Do Until r = 22
.SeriesCollection.NewSeries
.SeriesCollection(C).Values = wsm.Range("C1:C" & X).Offset(0, r)
.SeriesCollection(C).Name = ws2.Range("C3").Offset(0, r)
r = r + 2
C = C + 1
Loop
ElseIf ws2.Range("AA3").EntireColumn.Hidden = True Then
Do Until r = 24
.SeriesCollection.NewSeries
.SeriesCollection(C).Values = wsm.Range("C1:C" & X).Offset(0, r)
.SeriesCollection(C).Name = ws2.Range("C3").Offset(0, r)
r = r + 2
C = C + 1
Loop
ElseIf ws2.Range("AC3").EntireColumn.Hidden = True Then
Do Until r = 26
.SeriesCollection.NewSeries
.SeriesCollection(C).Values = wsm.Range("C1:C" & X).Offset(0, r)
.SeriesCollection(C).Name = ws2.Range("C3").Offset(0, r)
r = r + 2
C = C + 1
Loop
End If
End With
Any help would be greatly appreciated, have searched a lot on google but can't seem to find an answer as to how to set the first value of the x-axis