littlerascal
New Member
- Joined
- Oct 10, 2015
- Messages
- 3
Hello everyone
Below you see a part of a subroutine where I want to assign an array, which I create with a function (displayed further down) to an element of an array. To my understanding this should result in a jagged array. Unfortunately i get a run-time error 13: type mismatch on the line of the assignment.
Here you see the type assignment that was made at the beginning of the sub.
And these are the relevant parts of the function, which creates the array I want to assign to the array in the sub.
As you see both arrays are variant, so the types are the same. I just started to use VBA recently, so don't blame me, if I made a stupid mistake :P
Thanks a lot in advance for any reply.
Kind regards
littlerascal
Below you see a part of a subroutine where I want to assign an array, which I create with a function (displayed further down) to an element of an array. To my understanding this should result in a jagged array. Unfortunately i get a run-time error 13: type mismatch on the line of the assignment.
Code:
For Each cell In Sourcerange
If cell.Value <> "" Then
ReDim Preserve TransferArray(count)
TransferArray(count) = InitValues(Target(1), TargetCell(1))
count = count + 1
End If
Next cell
Here you see the type assignment that was made at the beginning of the sub.
Code:
Dim TransferArray() As Variant
And these are the relevant parts of the function, which creates the array I want to assign to the array in the sub.
Code:
Function InitValues(Sourcerange As range, Target As Sheets, TargetCell As range) As Variant()
...
Set TargetRange = range(TargetCell, range(TargetCell.Offset(0, 82)))
For Each cell In TargetRange
If cell.Interior.ColorIndex <> 19 Or 1 Then
InitArray(count) = cell.Value
count = count + 1
End If
Next
End function
As you see both arrays are variant, so the types are the same. I just started to use VBA recently, so don't blame me, if I made a stupid mistake :P
Thanks a lot in advance for any reply.
Kind regards
littlerascal