Welkom op Stack overflow.
As said, you cannot redo the function yourself. So use a temporary variable and pass its contents to your function at the end:
Public Function bmhussel(filemx As Variant) as Variant Dim rijaantal As Long Dim kolomaantal As Long Dim tmpArray as Variant rijaantal = UBound(filemx, 1) kolomaantal = UBound(filemx, 2) ReDim tmpArray (1 To rijaantal + 1, 1 To kolomaantal + 1) For i = 1 To rijaantal tmpArray(i, 1) = filemx(i, 1) tmpArray(i, 2) = filemx(i, 3) tmpArray(i, 3) = filemx(i, 5) tmpArray(i, 4) = filemx(i, 28) tmpArray(i, 5) = bucket(filemx(i, 28)) 'buckets maken next i bmhussel = tmpArray End Function
source share