简体   繁体   中英

Calling a function from a sub in VBA - qualifier error

I am trying to be more "object oriented" in my VBA code. However, I am having trouble passing variables through to functions. Here, I get an invalid qualifier error message on the IsEmpty function.

How can I correct my code?

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

Thank you!

Update your Function code to something like below:

Function toomuchdata(sheetStr As String, RngStr As String) As Boolean
    toomuchdata = IsEmpty(Sheets(sheetStr).Range(RngStr).Value)
End Function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM