First, build a simple diagram, record it with a macro, and then modify it for big data.
The following is what I recorded.
Sub draw a line chart ()
Charts. increase
ActiveChart。 ChartType = xlLine
ActiveChart。 set Source data Source:= Sheets(" sheet 1 ")。 Range("A5:G5 "),PlotBy:= _
xlRows
ActiveChart。 SeriesCollection( 1)。 XValues = "=Sheet 1! R9C 1:R9C7 "
ActiveChart。 Location, where: =xlLocationAsObject, Name:="Sheet 1 "
End joint
A5:G5 is the data area.
R9C 1:R9C7 represents the cell area where the X-axis mark is located.
Line 9, column 1 (A9) to line 9, column 7 (G9)
If not, you can delete this line and get it, and then the abscissa will automatically be 123456.
Sub draw a line chart ()
Charts. increase
ActiveChart。 ChartType = xlLine
ActiveChart。 set Source data Source:= Sheets(" sheet 1 ")。 Range("A5:G5 "),PlotBy:= _
xlRows
ActiveChart。 Location, where: =xlLocationAsObject, Name:="Sheet 1 "
End joint