Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
29 30 31 11
5 1 7 3 9 10 11 12 1 2 3 4 21 9 21 24 25 26 10 28 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Trying to append to file using an array | Excel Programming | |||
Append data from a column to separate table array | Excel Programming | |||
Consolidate data in an 2-dimension array in VBA | Excel Programming | |||
how to know which row to append for the last row | Excel Programming | |||
Qn: How to Append??? | Excel Programming |