+ Reply to Thread
Results 1 to 4 of 4

Merging - alternating row logic.

  1. #1
    Registered User
    Join Date
    12-18-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    2

    Merging - alternating row logic.

    Hi,

    I don't know if this is in the right section, but here goes.

    I have the following challenges.
    1 . I want to merge two worksheets into one, but the rows needs to alternate into the new sheet.
    ex:

    sheet A
    1
    2
    3
    4

    sheet B
    1
    2
    3
    4

    Sheet C
    1: A1
    2: B1
    3: A2
    4: B2
    5: A3
    6: B3
    7: A4
    8: B4

    2. I want to take a sheet and make a new sheet:
    ex:

    Sheet A
    1
    2
    3

    Sheet B
    1: A1
    2: A1
    3: A2
    4: A2
    5: A3
    6: A3

    I am making a script for data input - which is why the awkward setup.
    I have tried formulas Cell() and INDIRECT() without success. The problem is always the row number reference increasing exponentially.

  2. #2
    Forum Expert dredwolf's Avatar
    Join Date
    10-27-2012
    Location
    Clearwater,Canada
    MS-Off Ver
    Excel 2007
    Posts
    2,649

    Re: Merging - alternating row logic.

    would need a sample of the formulas you are actually using (to see what they are actually doing) but it sounds like you have a multiplication factor (*) involved in your fomula's somewhere
    A picture may be worth a thousand words, BUT, a sample Workbook is worth a thousand screenshots!
    -Add a File - click advanced (next to quick post), scroll to manage attachments, click, select add files, click select files, select file, click upload, when file shows up at bottom left, click done (bottom right), click submit
    -To mark thread Solved- go top of thread,click Thread Tools,click Mark as Solved
    If you received helpful response, please remember to hit the * of that post

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,724

    Re: Merging - alternating row logic.

    For your first query, you can use this formula in A1 in the third sheet:

    =IF(MOD((ROWS($1:1)-1),2)=0,INDEX('Sheet A'!A:A,INT((ROWS($1:1)-1)/2)+1),INDEX('Sheet B'!A:A,INT((ROWS($1:1)-1)/2)+1))

    then copy down.

    For your second query, you can use this:

    =INDEX('Sheet A'!A:A,INT((ROWS($1:1)-1)/2)+1)

    and copy that down.

    Hope this helps.

    Pete

    EDIT: Sample file attached
    Attached Files Attached Files
    Last edited by Pete_UK; 12-18-2012 at 06:12 AM.

  4. #4
    Registered User
    Join Date
    12-18-2012
    Location
    Norway
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Merging - alternating row logic.

    Quote Originally Posted by Pete_UK View Post
    For your first query, you can use this formula in A1 in the third sheet:

    =IF(MOD((ROWS($1:1)-1),2)=0,INDEX('Sheet A'!A:A,INT((ROWS($1:1)-1)/2)+1),INDEX('Sheet B'!A:A,INT((ROWS($1:1)-1)/2)+1))

    then copy down.

    For your second query, you can use this:

    =INDEX('Sheet A'!A:A,INT((ROWS($1:1)-1)/2)+1)

    and copy that down.

    Hope this helps.

    Pete
    Fantastic... it works.

    Even with my slight modification
    ex
    Sheet A:
    Column A--------------------------------- Column B ---------------------------------- Coulumn C
    1 (Headers different from other sheets)
    2 =INDEX(B!A:A;INT((ROWS($1:3)-1)/2)+1) =INDEX('C'!B:B;INT((ROWS($1:3)-1)/2)+1) =INDEX(B!E:E;INT((ROWS($1:3)-1)/2)+1)
    3 =INDEX(B!A:A;INT((ROWS($1:4)-1)/2)+1) =INDEX('C'!B:B;INT((ROWS($1:4)-1)/2)+1) =INDEX(B!K:K;INT((ROWS($1:4)-1)/2)+1)

    selecting the two rows (2 & 3) and copying them to n rows gives the alternation between column E and K that I desired...

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1