u144644
New Member
- Joined
- Sep 20, 2021
- Messages
- 6
- Office Version
- 365
- Platform
- Windows
- MacOS
- Mobile
- Web
Help, I am getting the error "Cannot assign to Array" calling on function to return array with values.
See code below.
Sub Get_Values()
Dim Arr(1 To 5) As String
Dim Txt As String
Txt = "Some Text passed to Function"
Arr = Split_Words(Txt) '<--- Error "Cannot assign to Array"
End Sub
Function Split_Words(ByRef Txt As String) As String()
Dim Arr(1 To 5) As String
'Code
Split_Words = Arr
End Function
See code below.
Sub Get_Values()
Dim Arr(1 To 5) As String
Dim Txt As String
Txt = "Some Text passed to Function"
Arr = Split_Words(Txt) '<--- Error "Cannot assign to Array"
End Sub
Function Split_Words(ByRef Txt As String) As String()
Dim Arr(1 To 5) As String
'Code
Split_Words = Arr
End Function