以下是引用rogerisally在2008-2-25 16:20:00的发言: 请教高手,下面的代码为什么不能够执行啊?老是在ActiveChart.SeriesCollection(1).XValues = "=(Left(Values,1000))"这里报错?谢谢! Sub test() ' ' test Macro ' Macro recorded 2008-2-25 by Roger_Dong
Dim Values As String Values = "" Sheets("ROGER").Select Charts("SALLY").Select ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _ "Line - Column on 2 Axes" ActiveChart.SetSourceData Source:=Sheets("ROGER").Range("E15") ActiveChart.SeriesCollection.NewSeries ActiveChart.SeriesCollection.NewSeries For i = 2 To 7 If Sheets("ROGER").Cells(5, i).Value <> "" Then Select Case i Case 2: Values = Values + "ROGER!R4C2," Case 3: Values = Values + "ROGER!R4C3," Case 4: Values = Values + "ROGER!R4C4," Case 5: Values = Values + "ROGER!R4C5," Case 6: Values = Values + "ROGER!R4C6," Case 7: Values = Values + "ROGER!R4C7" End Select End If Next ActiveChart.SeriesCollection(1).XValues = "=(Left(Values,1000))" ActiveChart.SeriesCollection(1).Values = "=(ROGER!R5C2,ROGER!R5C4,ROGER!R5C6)" ActiveChart.SeriesCollection(1).Name = "=ROGER!R5C1" ActiveChart.SeriesCollection(2).Values = "=(ROGER!R6C2,ROGER!R6C4,ROGER!R6C6)" ActiveChart.SeriesCollection(2).Name = "=ROGER!R6C1" With ActiveChart .HasTitle = True .ChartTitle.Characters.text = "AMAX MES" .Axes(xlCategory, xlPrimary).HasTitle = True .Axes(xlCategory, xlPrimary).AxisTitle.Characters.text = "DDD " .Axes(xlValue, xlPrimary).HasTitle = True .Axes(xlValue, xlPrimary).AxisTitle.Characters.text = "YYYY" .Axes(xlCategory, xlSecondary).HasTitle = False .Axes(xlValue, xlSecondary).HasTitle = False End With ActiveChart.HasLegend = True ActiveChart.Legend.Select Selection.Position = xlCorner ActiveChart.HasDataTable = True ActiveChart.DataTable.ShowLegendKey = True Charts.Add End Sub
请上传您的测试工作薄。 |