View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.misc
Max Max is offline
external usenet poster
 
Posts: 9,221
Default Merge data rows at fixed ratio

"AirBoss" wrote:
If the desired ratio was, say, 6:5,
how would the C:A1,C:B1,C:C1 logic be changed?
C: A1 logic would presumably be MOD 11, but how about the other 2, if
we assume a sequential merge with the extra "A" tacked onto the end?


We can actually do a similar 6:5 merger from the 2 source sheets: "A":"B",
viz. to have it in "C" as:

1st 6 rows from "A", followed by 1st 5 rows from "B",
then 2nd 6 rows from "A", followed by 2nd 5 rows from "B", and so on ..

Adapt it in this manner ..

In "C",

Put in A1:
=MOD(ROW(),11)
(yes, you're right, we use 11 here [as 6+5=11])

Put in B1:
=IF(AND($A10,$A1<7),OFFSET(A!$A$1,COUNTIF($A$1:$A 1,1)+COUNTIF($A$1:$A1,2)+COUNTIF($A$1:$A1,3)+COUNT IF($A$1:$A1,4)+COUNTIF($A$1:$A1,5)+COUNTIF($A$1:$A 1,6)-1,COLUMN(A1)-1),OFFSET(B!$A$1,COUNTIF($A$1:$A1,0)+COUNTIF($A$1: $A1,7)+COUNTIF($A$1:$A1,8)+COUNTIF($A$1:$A1,9)+COU NTIF($A$1:$A1,10)-1,COLUMN(A1)-1))

Copy B1 to C1. Then select A1:C1, copy down as far as required (copy down by
the total number of rows from "A" and "B"). Hide away col A. Cols B and C
will return the merged data rows from sheets: "A" & "B" intermingled in the
desired ratio of 6:5.
--
Max
Singapore
http://savefile.com/projects/236895
xdemechanik
---