I am trying to write a script for Excel and it keeps showing me an error "syntax error" at the line "Return ..." But I don't see any problem with the code. What am I doing wrong?
Function LoadCurrentUnitArray() As String()
Dim currentUnitArray() As String, unit_count As Integer, i As Integer
unit_count = WorksheetFunction.CountA(Worksheets(1).Columns(2))
ReDim currentUnitArray(unit_count)
For i = 1 To unit_count
currentUnitArray(i) = Cells(i + 1, 2).Value
Next
Return currentUnitArray
End Function