[英]VBA Application.Caller runtime error
我在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
我想获取激活了复选框的单元格,但是会引发运行时错误,我们使用Application.Caller.Address或.Row或.Column。 我为复选框分配了子Kontrollkästchen_KlickenSieAuf(),如果有人可以帮助我,我会非常高兴。
电贺
Application.Caller是一个String(控件的名称),而不是Object,并且该复选框没有row属性。 您需要使用:
ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row
例如。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.