When I plot my chart using one set of data(current 1), the graph shows the correct output. However when I plot 2 sets of data concurrently(current 1 and current 2), part of the graph is missing(circled in red) for both data consisting of current 1 and current 2. Btw the data are the same for both scenarios and no data are missing. As my data for them is huge, I can only show you the part of my data sample which looks like this as shown below for current 1 and current 2. I know the code for plotting graph of current1 only contains a lot of variables that you all might deem as the one that causes problem so let me clarify that totalsample1 and myarray values should be correct as they are the ones responsible for the data(Like the one shown in data sample for current1) for plotting the graph for current and all data for plotting are present in this case. So what could be the code that causes this problem and how to remedy it?
1st update:add wsf to range and cells
2nd update: replaced activechart with cht1
3rd update: Remove from For i = 2 To totalsample1 Step 1 till all the cht1.series collection
4th update: I make a simpler version of my code to plot graph for current 1.
5th update: And using the code suggested by @Dy.Lee, the ideal graph for current 1 is as shown.
Private Sub addgraph_Vramp1()
Application.ScreenUpdating = False
Dim i As Long
Dim wf As Workbook
Set wf = ActiveWorkbook
Dim wsf As Worksheet
Set wsf = wf.Worksheets("current1")
Dim shp1 As Shape
Dim Cht1 As Chart
Set shp1 = wsf.Shapes.AddChart
Set Cht1 = shp1.Chart
wsf.Activate
With Cht1
Cht1.SetSourceData Source:=wsf.Range("A1:BQ750")
Cht1.ChartType = xlXYScatterSmoothNoMarkers
Cht1.Axes(xlValue).ScaleType = xlLogarithmic
Cht1.Axes(xlValue).MaximumScale = 0.001
Cht1.Axes(xlValue).MinimumScale = 0.000000000000001
End With
With Cht1
.Legend.Delete
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Voltage"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Current"
End With
changes to the graph for the current 1 after using updated codes
changes to the graph after removing cht1.series collection(it still remains in the updated code just to let other knows what is being removed here)