Hello,
I have a user defined function as seen below that allows me to combine two non-adjacent columns into a contiguous array.
So, if I type "=makecontig(A1:A5,E1:E5)" into a cell, a single array is formed consisting of the two columns included in the formula. I would like to be able to edit this function so that it ignores a non-array entry.
For example, if i type "=makecontig(A1:A5,E1:E5, , )" or =makecontig(A1:A5,E1:E5,Nothing)" I would like it to ignore the error or blank parameter and only create a contiguous array for A1:A5 and E1:E5.
I imagine I need to include an If/Then statement somewhere in UDF but I cannot seem to figure out how to execute it properly.
Any help would be appreciated!
I have a user defined function as seen below that allows me to combine two non-adjacent columns into a contiguous array.
Code:
Function MakeContig(ParamArray av() As Variant) As Variant
Dim avOut() As Variant
Dim i As Long
Dim j As Long
ReDim avOut(1 To av(0).Count, 0 To UBound(av))
For j = 0 To UBound(av)
For i = 1 To av(j).Rows.Count
avOut(i, j) = av(j)(i)
Next i
Next j
MakeContig = avOut
End Function
So, if I type "=makecontig(A1:A5,E1:E5)" into a cell, a single array is formed consisting of the two columns included in the formula. I would like to be able to edit this function so that it ignores a non-array entry.
For example, if i type "=makecontig(A1:A5,E1:E5, , )" or =makecontig(A1:A5,E1:E5,Nothing)" I would like it to ignore the error or blank parameter and only create a contiguous array for A1:A5 and E1:E5.
I imagine I need to include an If/Then statement somewhere in UDF but I cannot seem to figure out how to execute it properly.
Any help would be appreciated!