Interspersed Sets of Rows from Two Sheets

michaeltsmith93

Board Regular
Joined
Sep 29, 2016
Messages
83
Hi all,

I am trying to combine sets of rows from two sheets. Here's a brief illustration of the desired product:

Sheet 3
Rows 1-5 of Sheet 1
Rows 1-5 of Sheet 2
Rows 6-10 of Sheet 1
Rows 6-10 of Sheet 2
...continuing in sets of five

I'm currently using the following formula:
=IF(INDIRECT(ADDRESS(1,COLUMN(A:A),,,$B$1))="","",INDIRECT(ADDRESS(1,COLUMN(A:A),,,$B$1))).

I've just put the sheet names in B1 and B2 so that I can use this sheet as a template.

I recognize that I could use EXACT, but I'm still toying with the idea of eliminating the cells that contain 0 (which has a meaning in my data set), and by setting the logic equal to 0, I can accomplish that quite simply. With that in mind though, my first question is this: is there a way that I could edit all of the cells in the sheet with this formula syntax and change the "" to 0 in one fell swoop?
Second question... this formula works great in terms of the COLUMN(A:A) function. However, if I use ROW(1:1), I obviously end up losing every other set of 5 rows from each sheet. I'd like to avoid having to manually input the row numbers for every row since there'll end up being +440, and I can't imagine that there isn't a way to do this. I'm a novice with Excel, so the Forum Searching Tips didn't help me too much--I'm sorry if this is a repeated topic! Thanks so much in advance!

Michael
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Are you willing to use a Vba script?

And when do you stop doing this? Just keep running till the last row of Sheet1 ??
 
Upvote 0
Assuming both of my question are "Yes" then use this Vba script

Code:
Sub Test()
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Dim Lastrowa As Long
Lastrow = Sheets(1).Cells(Rows.Count, "A").End(xlUp).Row
Lastrowa = Sheets(3).Cells(Rows.Count, "A").End(xlUp).Row
    For i = 1 To Lastrow Step 5
        Sheets(1).Rows(i).Resize(5).Copy Destination:=Sheets(3).Rows(Lastrowa)
        Lastrowa = Sheets(3).Cells(Rows.Count, "A").End(xlUp).Row + 1
        Sheets(2).Rows(i).Resize(5).Copy Destination:=Sheets(3).Rows(Lastrowa)
        Lastrowa = Sheets(3).Cells(Rows.Count, "A").End(xlUp).Row + 1
    Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thank you so much! I really appreciate it. This data might end up in an academic paper, so I'd love to acknowledge you by name--feel free to inbox me!
Michael
 
Upvote 0
Glad I was able to help you. Come back here to Mr. Excel next time you need additional assistance. Just name me "George"
Thank you so much! I really appreciate it. This data might end up in an academic paper, so I'd love to acknowledge you by name--feel free to inbox me!
Michael
 
Upvote 0

Forum statistics

Threads
1,215,487
Messages
6,125,075
Members
449,205
Latest member
Healthydogs

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top