Is there a formula to pull all the rows from multiple worksheets onto a single worksheet?

alexcr

Board Regular
Joined
Oct 15, 2018
Messages
61
Office Version
  1. 365
Platform
  1. Windows
Let's say you have multiple worksheets with data, and they're each regularly changing, i.e. rows being added, rows being deleted, rows being edited, etc..

You want to have a single worksheet that pulls together the rows from all of these worksheets, and that automatically updates when any of the worksheets change. It would be ideal if you could dictate the order of the rows being pulled in, i.e. the rows from Worksheet A would be followed by the rows from Worksheet B, etc.. It would also be ideal if you could add in filters, if necessary, for the rows being pulled in, e.g. to only include rows from the worksheets that meet certain criteria.

Any recommendations on how to go about this using a formula-based approach?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
It can be done with formulas too:

Cell Formulas
RangeFormula
B2:B4B2=MATCH("ZZZZZZZ",INDIRECT("'"&A2&"'!a:a"))
A11:A30A11=IFERROR(INDEX($A$2:$A$8,MATCH(ROWS($A$11:$A11),1+(SUBTOTAL(9,OFFSET(B$1,0,0,ROW(B$1:B$8)-ROW(B$1)+1))))),"")
B11:B30B11=IF(A11<>"",COUNTIF(A$11:A11,A11),"")
D11:F30D11=IF($A11<>"",INDIRECT("'"&$A11&"'!"&ADDRESS($B11,COLUMNS($D11:D11))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.


Put the list of your sheets in A2:A8. The B2 formula figures out how many rows are on each sheets (based on the last used row in column A). Then the A11 formula duplicates the sheet name the required number of times, and the B11 formula is a row counter. Then the D11 formula get the data from the appropriate sheet and cell. You could add some type of filtering in the A2:A8 cells, depending on if the contents of those cells are constants or formulas.

So yes, there is a formula based approach, but Power Query is probably a better long term solution.
 
Upvote 0
It can be done with formulas too:

Put the list of your sheets in A2:A8. The B2 formula figures out how many rows are on each sheets (based on the last used row in column A). Then the A11 formula duplicates the sheet name the required number of times, and the B11 formula is a row counter. Then the D11 formula get the data from the appropriate sheet and cell. You could add some type of filtering in the A2:A8 cells, depending on if the contents of those cells are constants or formulas.

So yes, there is a formula based approach, but Power Query is probably a better long term solution.

Thanks, @Eric W. Sorry for the dumb question, but how do I download the worksheet/workbook that you inserted into your post?
 
Upvote 0
You just need to click the copy icon & then paste onto A1 of a blank sheet
 

Attachments

  • Copy icon.png
    Copy icon.png
    5 KB · Views: 34
Upvote 0
You just need to click the copy icon & then paste onto A1 of a blank sheet

Ah, got it, @Fluff. But how does that work here, since this is a setup that's supposed to work across multiple worksheets? Unless I'm misunderstanding the approach that @Eric W used.
 
Upvote 0
You will need to set the other sheets up yourself
 
Upvote 0
Right, you didn't say anything about how your sheets looked, so I set up a very generic example. To recreate my example, open a new workbook, and add 4 sheets named Sheet1, Sheet2, Sheet3, and Sheet4. On Sheets 2-4 enter some random data in columns A:C. Make sure the last value in column A in each sheet is a text value. Then go to Sheet1 and paste the formulas from post 3 like Fluff explained. Starting in row 11, you should see the data you entered on Sheets 2-4.

This is just a basic example, and there are a lot of ways to adapt this to your workbook. The values in columns A of the other sheet could be numeric. You could hide columns A:B on Sheet1. The values on Sheet1!A1:A8 could be formulas instead of constants, allowing you to filter. You could drag the D11 formula further to the right to get more columns.

But it all depends on what your workbook looks like, and what your ultimate goal is.
 
Upvote 0
Right, you didn't say anything about how your sheets looked, so I set up a very generic example. To recreate my example, open a new workbook, and add 4 sheets named Sheet1, Sheet2, Sheet3, and Sheet4. On Sheets 2-4 enter some random data in columns A:C. Make sure the last value in column A in each sheet is a text value. Then go to Sheet1 and paste the formulas from post 3 like Fluff explained. Starting in row 11, you should see the data you entered on Sheets 2-4.

This is just a basic example, and there are a lot of ways to adapt this to your workbook. The values in columns A of the other sheet could be numeric. You could hide columns A:B on Sheet1. The values on Sheet1!A1:A8 could be formulas instead of constants, allowing you to filter. You could drag the D11 formula further to the right to get more columns.

But it all depends on what your workbook looks like, and what your ultimate goal is.

Thank you, @Eric W. I've followed your guidance and put together a workbook that replicates what you set up.

I think I understand most of how this is working, with a couple exceptions...

1) Cells B2-B4. I get that these functions count how many rows are in each worksheet, but what's the significance of the "ZZZZZZZ"in these functions?

2) Cells B11-B20. I'm totally lost on how these functions work. If it's too complicated to explain, no worries, I'll just put my trust in them ;).
 
Upvote 0
Did you look at the tutorial I provided? You have not commented on that.
 
Upvote 0

Forum statistics

Threads
1,215,472
Messages
6,125,011
Members
449,204
Latest member
tungnmqn90

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