View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
AirBoss AirBoss is offline
external usenet poster
 
Posts: 7
Default Merge data rows at fixed ratio

Max,

Looks good. Pardon my ignorance, but is this a macro?

- AirBoss


Max wrote:
For example, 200 rows in Sheet A and 100 rows in Sheet B, merged into
Sheet C with 300 rows, merged at the 2:1 ratio A:B, as 2 rows from A,
one row from B.


Here's a crack at this ..

In sheet: A
data is within A1:B200, eg

1 11
2 12
3 13
4 14
5 15
6 16
etc

In sheet: B
data is within A1:B100, eg

100 1000
200 2000
300 3000
400 4000
500 5000
600 6000
etc

Then in a new sheet: C,

Put in A1:
=MOD(ROW(),3)

Put in B1:
=IF($A1<0,OFFSET(A!$A$1,COUNTIF($A$1:$A1,1)+COUNT IF($A$1:$A1,2)-1,COLUMN(A1)-1),OFFSET(B!$A$1,COUNTIF($A$1:$A1,0)-1,COLUMN(A1)-1))

Copy B1 to C1. Then select A1:C1, copy down to C300. Hide away col A.

Cols B and C will return the merged data rows from sheets A & B intermingled
in the desired ratio of 2:1, viz we'd get:

1 11
2 12
100 1000
3 13
4 14
200 2000
5 15
6 16
300 3000
7 17
8 18
400 4000
9 19
10 20
500 5000
etc

--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---
"AirBoss" wrote in message
ups.com...
I have a requirement to merge a large number of groupings of two lists
(each an Excel worksheet) with differing numbers of rows, at the ratio
of their original sizes (number of rows).

This is always a fixed ratio, but most often at other than a 1:1 ratio.

For example, 200 rows in Sheet A and 100 rows in Sheet B, merged into
Sheet C with 300 rows, merged at the 2:1 ratio A:B, as 2 rows from A,
one row from B.

How would I do that in Excel?

Thanks.