|
如题,我这段代码可以在sheet"1月趋势监控1#"中于运行,EXCEL在打开同工作簙中其它sheet时就无法运行,请教如何修改
Sub tubiao1()
Dim cht As ChartObject
Dim col As Long
On Error Resume Next
ActiveSheet.ChartObjects.Delete
ActiveSheet.DataLabels.Delete
ActiveSheet.Charttitles.Delete
On Error GoTo 0
Set sh = Worksheets("1月趋势监控1#")
With sh
col = .Range("xfd1").End(xlToLeft).Column
End With
With Worksheets("1月趋势监控1#").Range("B1", "xfd3")
Set cht = Worksheets("1月趋势监控1#").ChartObjects.Add(10, 200, 800, 400)
With cht
.Name = "results"
With .Chart
.ChartType = xlLineMarkers
.SetSourceData Source:=Worksheets("1月趋势监控1#").Range(Range("B1"), Cells(3, col)), PlotBy:=xlRows
.SetElement msoElementChartTitleCenteredOverlay
.ApplyDataLabels ShowValue:=True
.HasTitle = True
.ChartTitle.Text = Range("A2") & "投入趋势图"
End With
End With
End With
End Sub
|
|