我想创建一个带有链接表的饼图,但是当我单击图形时,出现一些错误,代码的“ WorkSheetFunction.Index”行上出现“ Compile error Argument not optional”。 我是VBA编码的初学者。.请帮助 这是我的代码 xl page
此工作簿模块
Dim ChartObjectClass As New Class1
Dim ChartObjectClass2 As New Class2
Private Sub Workbook_Open()
Set ChartObjectClass.ChartObject = Worksheets(1).ChartObjects(1).Chart
Set ChartObjectClass2.ChartObject = Worksheets(1).ChartObjects(2).Chart
End Sub
课程模块
Option Explicit
Public WithEvents ChartObject As Chart
Private Sub ChartObject_MouseUp(ByVal Button As Long, ByVal Shift As Long, _
ByVal x As Long, ByVal y As Long)
Dim ElementID As Long, Arg1 As Long, Arg2 As Long
Dim myX As Variant, myY As Double
With ActiveChart
.GetChartElement x, y, ElementID, Arg1, Arg2
If ElementID = xlSeries Or ElementID = xlDataLabel Then
If Arg2 > 0 Then
myX=WorksheetFunction.Index(.SeriesCollection(Arg1).XValues.Arg2)
myY=WorksheetFunction.Index(.SeriesCollection(Arg1).Values.Arg2)
MsgBox "Series" & Arg1 & vbCrLf & """" & .SeriesCollection(Arg1)_
.Name & """" & vbCrLf & "Point" & Arg2 & vbCrLf & _
"x= " & myX & vbCrLf & "y= " & myY
Range("A1").Select
On Error Resume Next
Sheets("Series" & myX & "Detail").Select
Range("A1").Select
On Error GoTo 0
End If
End If
End With
End Sub
答案 0 :(得分:0)
在您的情况下,Index需要两个参数。第一个参数指定要从中返回值的值数组。第二个参数指定要返回的数组中的第n个元素。
:host {
margin: auto;
}
顺便说一句,您也可以省去WorksheetFunction.Index ...的使用。
<div class="container">
<app-clock></app-clock>
</div>