Hy, I have the following code to put a chart on a userform with multipage:
The chart is appering, but instead of the needed 30 values on the scale of the X-Axis it is show 35 values.
(this part in the code: XValues = ShJou.Range("A9:A38")
The ChartData is working right, it is show only 30 values.
What should I modify in the code?
Thank You!
Code:
Function chart_v1()LoadSheets
Dim MyChart As chart
Dim ChartData, ChartData2 As Range
Dim chartIndex As Integer
Dim ChartName, ChartName2 As String
Dim i As Long
chartIndex = MultiPage1.Value
Select Case chartIndex
Case 0
Set ChartData = ShSPC0.Range("B40:AE40")
ChartName = ShSPC0.Range("H3")
Set ChartData2 = ShSPC0.Range("B35:AE35")
ChartName2 = ShSPC0.Range("A35")
'''....more cases
End Select
Application.ScreenUpdating = False
Set MyChart = ShJou.Shapes.AddChart(xlXYScatterLines).chart
With MyChart
Do While .SeriesCollection.Count > 0
.SeriesCollection(1).Delete
Loop
End With
MyChart.SeriesCollection.NewSeries
MyChart.SeriesCollection(1).Name = ChartName
MyChart.SeriesCollection(1).Values = ChartData
MyChart.SeriesCollection(1).XValues = ShJou.Range("A9:A38")
MyChart.SeriesCollection.NewSeries
MyChart.SeriesCollection(2).Name = ChartName2
MyChart.SeriesCollection(2).Values = ChartData2
MyChart.SeriesCollection(2).XValues = ShJou.Range("A9:A38")
With ShJou.ChartObjects(1)
.Height = 300
.Width = 935
End With
Dim imageName As String
imageName = Application.DefaultFilePath & Application.PathSeparator & "TempChart.gif"
MyChart.Export Filename:=imageName, FilterName:="GIF"
ShJou.ChartObjects(1).Delete
Application.ScreenUpdating = True
v1.Image1.Picture = LoadPicture(imageName)
'''....more pictures to show
End Function
The chart is appering, but instead of the needed 30 values on the scale of the X-Axis it is show 35 values.
(this part in the code: XValues = ShJou.Range("A9:A38")
The ChartData is working right, it is show only 30 values.
What should I modify in the code?
Thank You!