View Single Post
  #48   Report Post  
Posted to microsoft.public.excel.programming
Alan Beban Alan Beban is offline
external usenet poster
 
Posts: 200
Default Append One Array to Another, and Consolidate

Albert,

If the functions in the freely downloadable file at
http://home.pacbell.net/beban were available to your workbook, here is
an example of another way the task might be accomplished (variables are
not declared):

Sub CallDeleteDuplicateRows()
arr1 = Range("A1:D3")
arr2 = Range("A5:D7")
iRows = UBound(arr1) - LBound(arr1) + 1 _
+ UBound(arr2) - LBound(arr2) + 1
iCols = UBound(arr1, 2) - LBound(arr1, 2) + 1
arr = MakeArray(arr1, arr2, 1)
arr = ArrayReshape(arr, iRows, iCols)
Range("A21").Resize(UBound(arr) - LBound(arr) + 1, _
UBound(arr, 2) - LBound(arr, 2) + 1).Value = _
DeleteDuplicateRows(arr)
End Sub

Function DeleteDuplicateRows(arr)
For i = UBound(arr) To 2 Step -1
For j = i To 2 Step -1
If RowsEqual(Application.Index(arr, i, 0), _
Application.Index(arr, j - 1, 0)) Then
arr = DeleteRow(arr, i)
Exit For
End If
Next j
Next i
DeleteDuplicateRows = arr
End Function


Albert wrote:
Yeah, I guess we should have gotten that clear from the start.

"Alan Beban" wrote:

Oh, I get it. Although the original poster mentioned consolidating
duplicate "elements", your algorithm consolidates duplicate rows.

Alan Beban