我在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的Cell,但它会抛出运行时错误,我使用Application.Caller.Address或.Row或.Column。 我分配了复选框子Kontrollkästchen_KlickenSieAuf() 如果有人可以帮助我,我会很高兴。
迎接
答案 0 :(得分:4)
Application.Caller是一个String(控件的名称)而不是Object,并且该复选框没有row属性。你需要使用:
ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row
例如。