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
.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With