Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Basic - Compile error: Invalid qualifier

Tags:

excel

vba

I am writing a custom Excel function in Visual Basic. When I run the function, I get the error: Compile error: Invalid qualifier on mondayArray on the line For index = 0 To mondayArray.Length - 1. What is causing this error?

Function SumHours(monday, tuesday, wednesday, thursday, friday, saturday, sunday)
    Dim mondayHours As Integer

    Dim mondayArray() As String
    Dim splitArray() As String

    SumHours = 0

    If monday <> "/" Then
        mondayArray = Split(monday, " ")

        For index = 0 To mondayArray.Length - 1
            splitArray = Split(mondayArray(index), "-")
        Next

    End If
End Function
like image 889
Corey Wu Avatar asked May 14 '26 19:05

Corey Wu


1 Answers

.length is not a property of an array. Use the LBound function and UBound function to determine the extents (Lower Boundary and Upper Boundary) of an array.

        For index = LBound(mondayArray) To UBound(mondayArray)

I believe you are confusing the .length property from a collection; e.g. HtmlElementCollection.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!