Hello,
I am new to vbscript with excel .
With the help of website i have tried to automate the line chart creation using chartwizard. In my data the series keep on changing and the data also changing .
I have 6 series. Through pgm when i change the name of the series only for 5 series it could able to change .. 6th series it is not changing .
This is the code , can anyone tell me where i am making mistake.
SeriesCount = aChart.SeriesCollection.count
For i = 1 To SeriesCount
With aChart.SeriesCollection(i)
.Name = Cells(sRow, sCol).Value
' .Values =
.XValues = Range(Cells(11, 3), Cells(11, 4))
End With
sRow = sRow + 1
Next i
one more issue i am facing is the chart which i am generating using my pgm is not matching with the manually generated chart.
some issues is there on x and y axis . It is not plotting the X axis properly . Can you please tell me what are the important properties i should use it in x and Y axis.
Here is my code ..
Dim rge As String
Dim shtname As String
Dim oSeries As SeriesCollection
Dim sRow, sCol, SeriesCount, i As Integer
rge = Selection.Address()
'Store the sheet name.
shtname = ActiveSheet.Name
Application.ScreenUpdating = False
Set aChart = Charts.Add
sRow = 0
sCol = 0
SeriesCount = 0
i = 1
With aChart
.ChartWizard Source:=Sheets(shtname).Range(rge), _
Gallery:=xlLine, Format:=4, PlotBy:=xlRows, _
HasLegend:=True, _
Title:="OR9 USER CONSOLIDATION", CategoryTitle:="Quarters", _
ValueTitle:="No Users"
'isheet.Range(FirstColumn & row).Value
'For Each c In Sheets(shtname).Range(rge).Rows.count
sRow = Sheets(shtname).Range(rge).Row
sCol = Sheets(shtname).Range(rge).Column
' To format
SeriesCount = aChart.SeriesCollection.count
For i = 1 To SeriesCount
With aChart.SeriesCollection(i)
.Name = Cells(sRow, sCol).Value
' .Values =
.XValues = Range(Cells(11, 3), Cells(11, 4))
End With
sRow = sRow + 1
Next i
'Modify the category (x) axis.
' With .Axes(xlCategory)
' .TickLabelSpacing = 1
' .TickMarkSpacing = 1
' .AxisBetweenCategories = True
'
'End With
'Modify the value (y) axis.
'With .Axes(xlValue)
' .MinimumScale = 0
' .MaximumScaleIsAuto = True
' .MinorUnitIsAuto = True
' .MajorUnitIsAuto = True
' .Crosses = xlAutomatic
' .ScaleType = xlScaleLogarithmic
'.HasMajorGridlines = True
'.HasMinorGridlines = False
'End With
End With
'Turn screen updating back on.
Application.ScreenUpdating = True
End Sub
Thanks,
Malar