This looks like a simple problem but it's been driving me nuts the past couple of days. The following is the gist of a macro I'm working on, I'm trying to assign the return value of a function to an array in the main sub, but it's throwing a can't assign to array error. I've tried changing vbArr data type from string to variant, likewise data type of switch function. I'm sure the answer is something really basic but for the life of me, I can't see it.
VBA Code:
Option Base 1
Public Sub getArr()
Dim vbArr(1 To 2) As String, newArr(1 To 2) As Variant, k As Integer
vbArr(1) = a
vbArr(2) = b
newArr = switch(vbArr) 'this throws can't assign to array error
End Sub
Public Function switch(ByRef myArr()) As String()
Dim anArr(1 To 2) As String
anArr(1) = myArr(2)
anArr(2) = myArr(1)
End Function