Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #41   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Append One Array to Another, and Consolidate

I ran it with the new one. The result was

29 30 31 11
5 1 7 3
9 10 11 12
1 2 3 4
21 9 23 24
25 26 10 28

I.e., it simply merged the two arrays with the rows rearranged and
eliminated no duplicates.

Did you test it before reposting?

Alan Beban

Albert wrote:
Check out the final 5 lines of the procedure...
I replaced this (old):

ReDim ConsolidatedArray(1 To x - 1, 1 To UBound(Array2, 2))
For x = 1 To UBound(ConsolidatedArray, 1)
For Y = 1 To UBound(ConsolidatedArray, 2)
ConsolidatedArray(x, Y) = Array3(x, Y)
Next Y
Next x

with this (new):

Dim ThereAreDuplicates As Boolean
ThereAreDuplicates = False
If Not x = UBound(Array3, 1) Then
ThereAreDuplicates = True
ElseIf x = UBound(Array3, 1) Then
If Array3(UBound(Array3, 1), UBound(Array3, 2)) = "REPETIDO" Then
ThereAreDuplicates = True
End If
End If
If ThereAreDuplicates = True Then
ReDim ConsolidatedArray(1 To x - 1, 1 To UBound(Array2, 2))
ElseIf ThereAreDuplicates = False Then
ReDim ConsolidatedArray(1 To x, 1 To UBound(Array2, 2))
End If
For x = 1 To UBound(ConsolidatedArray, 1)
For Y = 1 To UBound(ConsolidatedArray, 2)
ConsolidatedArray(x, Y) = Array3(x, Y)
Next Y
Next x

  #42   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Append One Array to Another, and Consolidate

Sure I tested it.
Just re-tested it.
Works great here.

"Alan Beban" wrote:

I ran it with the new one. The result was

29 30 31 11
5 1 7 3
9 10 11 12
1 2 3 4
21 9 23 24
25 26 10 28

I.e., it simply merged the two arrays with the rows rearranged and
eliminated no duplicates.

Did you test it before reposting?

Alan Beban

Albert wrote:
Check out the final 5 lines of the procedure...
I replaced this (old):

ReDim ConsolidatedArray(1 To x - 1, 1 To UBound(Array2, 2))
For x = 1 To UBound(ConsolidatedArray, 1)
For Y = 1 To UBound(ConsolidatedArray, 2)
ConsolidatedArray(x, Y) = Array3(x, Y)
Next Y
Next x

with this (new):

Dim ThereAreDuplicates As Boolean
ThereAreDuplicates = False
If Not x = UBound(Array3, 1) Then
ThereAreDuplicates = True
ElseIf x = UBound(Array3, 1) Then
If Array3(UBound(Array3, 1), UBound(Array3, 2)) = "REPETIDO" Then
ThereAreDuplicates = True
End If
End If
If ThereAreDuplicates = True Then
ReDim ConsolidatedArray(1 To x - 1, 1 To UBound(Array2, 2))
ElseIf ThereAreDuplicates = False Then
ReDim ConsolidatedArray(1 To x, 1 To UBound(Array2, 2))
End If
For x = 1 To UBound(ConsolidatedArray, 1)
For Y = 1 To UBound(ConsolidatedArray, 2)
ConsolidatedArray(x, Y) = Array3(x, Y)
Next Y
Next x


  #43   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Append One Array to Another, and Consolidate

Albert wrote:
Sure I tested it.
Just re-tested it.
Works great here.


I ran the programs with ranges A1:D3 and A5:D7, and put the output in
A11:A16.

The first had
1 2 3 4
5 1 7 3
9 10 11 12

The second had
21 9 21 24
25 26 10 28
29 30 31 11

Can you run it on that test data and report your results.

Thanks,
Alan Beban
  #44   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Append One Array to Another, and Consolidate

29 30 31 11
5 1 7 3
9 10 11 12
1 2 3 4
21 9 21 24
25 26 10 28
  #45   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Append One Array to Another, and Consolidate

Albert wrote:
29 30 31 11
5 1 7 3
9 10 11 12
1 2 3 4
21 9 21 24
25 26 10 28


I thought duplicates were supposed to be eliminated from the
consolidated array!???

Alan Beban


  #46   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Append One Array to Another, and Consolidate

Albert wrote:
29 30 31 11
5 1 7 3
9 10 11 12
1 2 3 4
21 9 21 24
25 26 10 28


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

Alan Beban
  #47   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Append One Array to Another, and Consolidate

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

"Alan Beban" wrote:

Albert wrote:
29 30 31 11
5 1 7 3
9 10 11 12
1 2 3 4
21 9 21 24
25 26 10 28


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

Alan Beban

  #48   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to append to file using an array Susan Hayes Excel Programming 1 January 5th 06 08:55 AM
Append data from a column to separate table array miss_q Excel Programming 5 December 12th 05 11:01 PM
Consolidate data in an 2-dimension array in VBA Huyeote[_15_] Excel Programming 0 October 18th 05 01:31 AM
how to know which row to append for the last row tango Excel Programming 2 October 16th 04 02:23 PM
Qn: How to Append??? Michael Vaughan Excel Programming 1 September 19th 04 05:32 PM


All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"