VBA Application.Caller运行时错误

我在VBA中有以下代码:

Sub Kontrollkästchen_KlickenSieAuf() With ThisWorkbook.Sheets("Hinterlegungsmatrix Auswahl") Dim i, j, rowx, columnx As Integer rowx = Application.Caller.row 'I got here the run time error (object required)-->.row doesn't work columnx = Application.Caller.column 'I got here the run time error (object required)-->.column doesn't work If Worksheets("Hinterlegungsmatrix Auswahl").Cells(rowx, columnx).Value = True Then For i = 6 To 22 For j = 3 To 22 If (Worksheets("Hinterlegungsmatrix Auswahl").Cells(i, j).Interior.Color = RGB(250, 192, 144)) Or (Worksheets("Hinterlegungsmatrix Auswahl").Cells(i, j).Interior.Color = RGB(83, 142, 213)) Or (Worksheets("Hinterlegungsmatrix Auswahl").Cells(i, j).Interior.Color = RGB(242, 221, 220)) Then Worksheets("Hinterlegungsmatrix Auswahl").Cells(i, j).Value = True End If Next j Next i End If End With End Sub 

我想获取checkbox激活的单元格,但它会引发运行时错误,我使用Application.Caller.Address或.Row或.Column。 我分配的checkboxKontrollkästchen_KlickenSieAuf()我会很高兴,如果有人可以帮助我。

电贺

Application.Caller是一个String(控件的名称)而不是一个Object,并且该checkbox没有行属性。 你需要使用:

 ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row 

例如。