Combine data from multiple sheets in excel
Question:
Problem description (simplified of course):
I have a list of employees (by ID number) and date (by yr & mon) of when they were assigned a certain duty (task). This is in a Work book, on a TAB. Each TAB is a separate month (first is Jan, 2nd is Feb, etc.). I have 12 tabs (12 worksheets) in workbook. Each TAB, a single month, has a list of ID numbers. Some IDs may repeat on different worksheets, that is, some may be in multiple months and some may be in just two or three months or just one month. An ID number will shown only once in a month for a single task (duty). Abbreviated example is below.
Is it possible to combine the data, by function, or formula, or VBasic) to a 13th worksheet automatically and:
1. Show a list of all ID numbers in order (without repeating).
2. Show Jan data in col B, Feb data in col C, etc., and some columns will be blank because the ID had no assignment that month, and will not be on the worksheet for that month.
Is there a formula, or function, or does it have to be done in VBasic? (Is it even possible?)
I have the workbook with 12 tabs in it, and now have to manually put the ID columns side by side and copy and slide down one side on the other to get them to match, and repeat the process 12 times to get the yearly data on one worksheet.
Ex:
For Jan:
ID Duty Asgn.
01 C
05 F
09 D
15 X
23 P
For Feb:
ID Duty Asgn.
02 M
05 Q
08 A
12 R
20 W
Combing Jan and Feb would be:
ID Duty Asgn.
01 C
02 M
05 F Q
08 A
09 D
12 R
15 X
20 W
23 P
This would be repeated for each month to build all 12 col months.
Very Respectfully,
Dave Bonar
Answer:
First I thought your question required vba but here is the answer using only Excel formulas.
Maximum ID number from multiple sheets
Formula in cell B1:
=MAX(Jan:Mar!A2:A1000) + Enter
Create a sorted unique distinct list of numbers originating from multiple sheets
We are going to use the number calculated in B1 (28) in array formula in cell A4 (bolded):
=SMALL(IF(FREQUENCY(Jan:Mar!$A$2:$A$1000, ROW($1:$28))<>0, ROW($1:$28), ""), ROW(A1)) + CTRL + SHIFT + ENTER copied down as far as needed.
Combine data from multiple sheets
Formula in B4:
=IF(ISERROR(MATCH(A4, Jan!$A$2:$A$10, 0)), "", INDEX(Jan!$B$2:$B$10, MATCH(A4, Jan!$A$2:$A$10, 0))) + CTRL + SHIFT + ENTER copied down as far as needed.
Formula in C4:
=IF(ISERROR(MATCH(A4, Feb!$A$2:$A$10, 0)), "", INDEX(Feb!$B$2:$B$10, MATCH(A4, Feb!$A$2:$A$10, 0))) + CTRL + SHIFT + ENTER copied down as far as needed.
Formula in D4:
=IF(ISERROR(MATCH(A4, Mar!$A$2:$A$10, 0)), "", INDEX(Mar!$B$2:$B$10, MATCH(A4, Mar!$A$2:$A$10, 0))) + CTRL + SHIFT + ENTER copied down as far as needed.
Download excel tutorial file
Get data from each sheet.xls
(Excel 97-2003 Workbook *.xls)
Functions in this article:
IF(logical_test;[value_if:true];[value_if_false])
Checks whether a condition is met, and returns one value if TRUE, and another value if FALSE
INDEX(array,row_num,[column_num])
Returns a value or reference of the cell at the intersection of a particular row and column, in a given range
ROW(reference) Returns the rownumber of a reference
SMALL(array,k) Returns the k-th smallest row number in this data set.
MAX(number1,[number2],)
Returns the largest value in a set of values. Ignores logical values and text.
FREQUENCY(data_array, bins_array)
Calculates how often values occur within a range of values and then returns a vertical array of numbers having one more element than Bins_array.
MATCH(lookup_value;lookup_array; [match_type]
Returns the relative position of an item in an array that matches a specified value
ISERROR(value)
Checks whether a value is an error and returns TRUE or FALSE
Related posts:
- Return unique and duplicate numerical data entries from multiple sheets (3D range) in excel
- Split data across multiple sheets in excel (vba)
- Count unique distinct numbers across multiple sheets (3D range) in excel
- Search for multiple text strings in multiple cells and use in data validation in excel
- Create a list with most recent data available in excel
- Return multiple values if in range in excel
- Categorize values into multiple columns (excel formulas)
- Filter duplicates within same date, week or month in excel
- Vlookup with 2 or more lookup criteria and return multiple matches in excel
- Lookup with multiple criteria and display multiple search results using excel formula, part 4



March 1st, 2010 at 11:23 am
Have you thought about adding some sort of bookmarking buttons or links to your blog posts?
March 3rd, 2010 at 2:36 am
It looks like you are assuming that everyone knows that this technique can return the # of unique data entries from a real 3D range.
=SUM(IF(FREQUENCY(Jan:Mar!$K$1:$L$3,Jan:Mar!$K$1:$L$3)>0,1))
I am pretty sure that no one has ever done this before, so congratulations!
March 3rd, 2010 at 9:46 am
David Hager,
Thanks!!
/Oscar
March 18th, 2010 at 1:54 pm
Hi Oscar,
I am not sure if my problem is something which is similar to what you have done here or not. I hope that you would know and could help me so I will give it a try....
I have multiple worksheets in a workbook. Each worksheets is project specific. Each worksheet contains almost identical format. The columns I am interested in each workshets are "Date Plan", "Date Compelted" and "variance" and "Project Code"
I then want data from all these column to be extracted in a Report worksheet and later want to do a trend chart by sorting all dates in chronological order.
Key bit to start is how do I get data out from worksheets. Esentially I want all the data without any loss. There are chances that some of the data between worksheet1 & 2 could be identical, apart from project code.
Also, preference is that this coding or formula should work for any future addition to worksheet data and workbook worksheets.
I am not sure if I manage to explain everything very clearly. Please do not hesitate to email me if you need more clarification.
Best Regards,
Jignesh
March 19th, 2010 at 10:03 pm
Hi Jignesh!
Interesting question!
I´ll post an answer as soon as I can.
March 22nd, 2010 at 1:07 pm
Thanks Oscar,
Really appreciate your input and help. I am wondering if there would be a way to write a formula with lookup function to get the date from various worksheet...
say if I ask to search for January data then I am expecting January data from all work sheet to be extracted and copied in my Report worksheet.
I can then have 12 X 4 ( For Key Columns - date plan / completed / variance and project code) different columns with all monthly data from various worksheet.
I would then need to plot a chart using the variance data....
Problem is I am not sure if this is possible and if yes, how to write such fomula
March 24th, 2010 at 3:56 pm
Hello, Oscar,
First of all id like to thank you for your blog. I have found many very usefull tips and answers, but still i have one problem that i cant solve by my self. So im asking for your help.
Here is the problem:
i have a data table with 2 columns:
A B
2.93 12.8
2.94 12.2
3 8.38
3.03 6.76
3.04 5.33
3.06 6.36
Lets say i have a cell with number 3. I need to find a number in column A that has a number >= than 3, but also has the smallest number in column B.
(with my cell = 3 it would be 3.04 from A and 5.33 from B)
Simple vlookup gives me first >= number, but in most cases in column B is not the smalest number.
I hope you can help me,
Best regards,
Liudas
March 24th, 2010 at 9:48 pm
Liudas,
See this post: http://www.get-digital-help.com/2010/03/24/lookup-using-two-criteria-in-excel/
March 24th, 2010 at 9:53 pm
Jignesh,
I think I can solve your problem using vba. I hope I can post a solution here soon.
March 29th, 2010 at 5:19 pm
Jignesh,
see this post: http://www.get-digital-help.com/2010/03/29/consolidate-sheets-in-excel-vba/
May 7th, 2010 at 9:51 am
Thanks a lot Oscar! You are genius! Thanks again!
June 9th, 2010 at 12:16 pm
hi..i have been working on my problem for quite sometime now...i wud b very thankful if u cud provide me the solution.
problem: i have created a workbook containing 12 sheets each corresponding to a month. each sheet has 3 fields-region,premium, claims and ICR. Mow i want to consolidate this data using drop down menus such that wen i select say january month from the drop down, january months data for all the regions shoud be dsiplayed ans similarly for all other months. in addition region should also be in a drop down i.e. wen viewing the data for a particular month, i could select a region and then view its data.
Pls help me in this
June 30th, 2010 at 6:55 pm
Hello,
Is is possible to get this work with ID-names not numbers?
Here: "Create a sorted unique distinct list of numbers originating from multiple sheets"
Lets say if i have the id's like ALFA, BETA, GAMMA, DELTA etc. is it possible to collect all these unique names and combine some data from their rows and sheets? I assume the function small doesn't work anymore?
Thanks for good work!
July 1st, 2010 at 7:35 am
Tjena Jan-Erik!
As far as I know using formulas, no!
But maybe pivot tables can solve your problem?
Excel Pivot Table Tutorial -- Multiple Consolidation Ranges
July 13th, 2010 at 9:51 am
Hi,
Same logic i need to be use , but there is the problem when my id nos are more then the No.of row values i.e in excel 2007 total no of row is 1048575 , but hear my id value is more then rowno value i.e 5505982 so that i am not able to get the output .
can you plz sugest ..
Thanks
R Thamu
July 15th, 2010 at 10:19 pm
Thamu,
Interesting question!
I never thought row function created numerical limits. 1 to 1048575.
I´ll comment here as soon as I have an answer.