gpt4 book ai didi

VBA Application.Caller 运行时错误

转载 作者:行者123 更新时间:2023-12-03 02:04:38 29 4
gpt4 key购买 nike

我在 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 是一个字符串(控件的名称)而不是一个对象,并且复选框没有 row 属性。您需要使用:

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

例如。

关于VBA Application.Caller 运行时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24649061/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com