我想在我的VBA代码中更加“面向对象”。但是,我无法将变量传递给函数。在这里,我在IsEmpty
函数上收到了无效的限定符错误消息。
如何更正我的代码?
Sub test_too_much_data()
If toomuchdata("Data input", "B1018") = False Then
MsgBox ("Sorry, the tool can only accomodate 1000 rows.")
Exit Sub
End If
End Sub
Function toomuchdata(sheet As String, range As Variant) As Boolean
toomuchdata = IsEmpty(Sheets("String")).range(range)
End Function
谢谢!
答案 0 :(得分:0)
将您的Function
代码更新为以下内容:
Function toomuchdata(sheetStr As String, RngStr As String) As Boolean
toomuchdata = IsEmpty(Sheets(sheetStr).Range(RngStr).Value)
End Function