|
![](https://clubstatic.excelhome.net/image/common/ico_lz.png)
楼主 |
发表于 2011-11-2 08:57
|
显示全部楼层
本帖最后由 single_star 于 2011-11-2 09:11 编辑
boyou3039 发表于 2011-11-2 07:48 ![](http://club.excelhome.net/static/image/common/back.gif)
比较多
先上一例看看是否是我操作的错误
2007打开后没有运行宏的时候表示是正常的,运行宏后就不对了
这样看来似乎是宏没有正常运作所致,你把以下宏中的
On Error Resume Next
myChartClass.SeriesCollection(i).DataLabels.Delete
删掉或注解后再运行看错误原因
'******************************************
Private Sub myChartClass_Calculate()
'Application.EnableEvents = False
n = myChartClass.SeriesCollection.Count
If n = 0 Then Exit Sub
ref1 = ActiveWorkbook.Names("log1").RefersToRange
ref2 = ActiveWorkbook.Names("chart1").RefersToRange
For i = 1 To n
p = myChartClass.SeriesCollection(i).Points.Count
If p = 0 Then Exit For
'On Error Resume Next
'myChartClass.SeriesCollection(i).DataLabels.Delete
myChartClass.SeriesCollection(i).DataLabels.Delete
myChartClass.SeriesCollection(i).ApplyDataLabels AutoText:=True, ShowValue:=True
For j = 1 To p
a = Val(myChartClass.SeriesCollection(i).Points(j).DataLabel.Characters.Text)
b = Application.WorksheetFunction.Match(a, ref1, 1)
c = Application.WorksheetFunction.Index(ref2, b)
myChartClass.SeriesCollection(i).Points(j).DataLabel.Characters.Text = c
Set d = Range("chart1").Offset(b - 1, 0).Resize(1, 1).Font
With myChartClass.SeriesCollection(i).Points(j).DataLabel.Font
.Name = d.Name
.Size = d.Size
.ColorIndex = d.ColorIndex
End With
Next
Next
'Application.EnableEvents = True
End Sub
|
|