VBA图表x轴:为什么是行号。 而不是价值?

我正在尝试使用VBA在Excel上创build图表。 但是x轴不断显示行号而不是行中的值。 这是我目前的代码。 难道我做错了什么? y轴是正确的

If CheckBox4.Value = False Then If CheckBox1.Value = True Then 'S11 S22 ActiveSheet.Shapes.AddChart.Select With ActiveChart .HasTitle = True .ChartTitle.Text = "S11 & S22" .ChartType = xlXYScatterLinesNoMarkers .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Frequency/GHz" .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "/dB" .SetSourceData Source:=Range("B2:T5") Do Until .SeriesCollection.Count = 0 .SeriesCollection(1).Delete Loop .SeriesCollection.NewSeries .SeriesCollection(1).Name = "S11" .SeriesCollection(1).XValues = Range("A9:A" & j) .SeriesCollection(1).Values = Range("B9:B" & j) .SetElement (msoElementPrimaryCategoryGridLinesMinorMajor) .SetElement (msoElementPrimaryValueGridLinesMinorMajor) ' .SetElement (msoElementPrimaryCategoryAxisLogScale) .SeriesCollection.NewSeries .SeriesCollection(2).Name = "S22" .SeriesCollection(2).XValues = Range("A9:A" & j) .SeriesCollection(2).Values = Range("H9:H" & j) With .Parent .Height = 300 .Width = 500 .Top = 50 .Left = 600 End With End With End If 

提前谢谢你们!

试试replcaing

 .SeriesCollection(1).XValues = Range("A9:A" & j) 

有:

 .SeriesCollection(1).XValues = "=" & Range("A9:A" & j).Address(False, False, xlA1, xlExternal)