I come from a Java background - Can anyone explain why this is disallowed?
And how best to achieve this?
Public Function testMe() As Variant() ReDim abc(0 To 1, 0 To 1) As Long testMe = abc End Function
I come from a Java background - Can anyone explain why this is disallowed?
And how best to achieve this?
Public Function testMe() As Variant() ReDim abc(0 To 1, 0 To 1) As Long testMe = abc End Function
[VBA]
Sub test()
Dim t, msg
For Each t In testMe
msg = msg & t
Next
MsgBox msg
End Sub
Public Function testMe() As Variant
ReDim abc(0 To 1, 0 To 1) As Long
abc(0, 0) = 1
abc(1, 0) = 2
abc(0, 1) = 3
abc(1, 1) = 4
testMe = abc
End Function
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Thanks - But why does this work conceptually?
How can you declare a function that returns a variant() - Notice the array on the signature.
Thats my question
Sorry, I'm not much on theory. I'm sure someone else will come along though.
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Anyone please? I am keen to know the answer here...
Thanks