Stacking two list of data on top of each other in excel - excel

I have two excel sheets with one column each.
Sheet1
A
Fruits
Orange
Apple
Grapes
Sheet2
B
Vegetables
Tomatoes
Potatoes
Now, how do I use excel formula and populate on a third sheet stacking just the values
A
Orange
Apple
Grapes
Tomatoes
Potatoes

If your data has a header in Sheet1!A1 and Sheet2!A1 then in Sheet3!A1 you could use (and drag down):
=IF(ROW()<=ROWS(Sheet1!$A$2:$A$4),
Sheet1!A2,
SUBSTITUTE(
INDEX(Sheet2!A:A,
ROW()-ROWS(Sheet1!$A$2:$A$4)+1),
"",""))
If the row number in the new sheet is smaller than or equal to the count of rows in the range of Sheet1 then the result is Sheet1!A2:A4 if the row is greater it'll index Sheet2 column A and will get the result for in that range with the row that equals to the current row number minus the total count of rows of Sheet1!A2:A4 + 1 to take the header into account.
In Office 365 a simple =HSTACK(Sheet1!A2:A4,Sheet2!A2:A3) would do.

Related

Accumulate total sum based on value of cells across multiple worksheets

I am looking for a formula in excel that will calculate the sum of a given cell based on the value in a different cell, across all worksheets.
That is, I would only like the sum of a cell based on the criteria of another column, across multiple worksheets if the value matches.
Worksheet 1
19 apples
2 oranges
57 pears
Worksheet 2
2 apples
13 oranges
3 pears
Summary
apples: (from all worksheets)
I would like to know how many apples I have total from every worksheet, but have not been able to properly work out the sum-if...if thats the correct tool. The sums I want to add are always in the same column across worksheets, and the criteria is always in the same column. But criteria column is never in the same order
The solution I used was this:
Input this formula into the desired Total Cell on your summary or totals worksheet
=SUM(Worksheet1:Worksheet2!<cell>)
So if in worksheet1 you have
A1 B1
19 apples
2 oranges
57 pears
And in worksheet2 you have
A1 B1
2 apples
13 oranges
3 pears
The formula that would go on your summary or totals worksheet for total apples would be as follows:
=SUM(Worksheet1:Worksheet2!A1)

Compare and Remove Duplicate Rows based off TWO columns VBA

I currently have a code where my duplicates will be removed based off of one column. I would like to join column 1 and column 2 as strings (I think that would be the easiest way) and remove the duplicates. Currently I have the code:
Range("A1:A6").RemoveDuplicates Columns:=1, Header:=xlNo
I would like to have it so it compares column 1 and column 2 TOGETHER.
For example Column 1 has:
(A1) Apple
(A2) Pear
(A3) Pear
(A4) Apple
Column 2 has:
(B1) Red
(B2) Blue
(B3) Blue
(B4) Orange
In this case, only Row 2 and Row 3 are duplicates. Not Row 1 and Row 4 because you would be comparing two columns instead of one.
Thank you! Hope this made sense.
Include the whole range and use Array to include both columns:
Range("A1:B6").RemoveDuplicates Columns:=Array(1,2), Header:=xlNo

Excel: How to add a column from other sheet based on a key column?

I have 2 list. Both have a lot of column. I would like to insert a column from Sheet2 to Sheet1 based on a ceratin key column. Also sheet2 have much more rows than sheet1 so it ll be inserted only partly and still there ll be elements with no matches. For an example:
Sheet1:
Names ID Car Color
John 1 Audi Empty
Andy 4 Toyota Empty
Mike 3 BMW Empty
Tony 2 Suzuki Empty
Sheet2:
ID Cost Color
6 200 Blue
3 200 Red
4 300 Green
5 100 Red
1 50 Black
I would like to get the "color" from Sheet2 to Sheet1 by using the "ID". Using Excel 2010. I suspect I need INDEX+MATCH combination, but the examples I can find are not detailed and more simple so I coudn't figure out how to use them.
How about inserting this formula on Column D in the first row, then dropping the formula down:
=VLOOKUP(B1,Sheet2!$1:$1048576,3,FALSE)
Or to find the column that contains "Color", use Index Match Match, as follows:
=INDEX(Sheet2!$1:$1048576,MATCH(Sheet1!B2,Sheet2!A:A,0),MATCH("Color",Sheet2!$1:$1,0))
This will find the value in Column B in Sheet2 and give you the row number, then it will find the Column that contains "Color" and return the Column number, with those two numbers Index will return your color.

text matching with logical function?

Please help me to formulate the following formula:
Actually I am trying to make a costing sheet for recipes.. I am listing all the items in sheet 1 and on sheet 2 all recipes with their quantities of items..
sheet 1
A B
1 item price/gm
2 chicken 10
Sheet 2
A B C
1 item Qty (in gm) cost
2 chicken 150 formula?
now in sheet 2 C2 I need a formula that matches sheet2 A2 with sheet1 column A and then multiply sheet2 B2 with sheet1 B2.. and this will same for all the items in sheet2.. if I put any item in sheet2 it looks up in sheet1 and then multiply the price with qty in sheet2..
Use VLOOKUP:
=B2*VLOOKUP(A1,'Sheet 1'!A:B,2,false)

Need to match data in different sheets and replace data in another cell if it's a match

I need to match data in column A2 and so on in sheet 1 to data in column A2 and so on in sheet 2. If the data in column A of sheet 1 and sheet 2 match I need the data in column B & C of sheet 2 to replace data in column B & C of sheet 1. I know VERY little about doing this kind of stuff so any help would be GREATLY appreciated!
SHEET 1
A B C
2 12345 5.35 9.95
3 15874 4.22 10.99
4 11111 2.24 5.99
5 98745 5.33 9.95
6 88552 4.24 8.95
SHEET 2
A B C
2 11111 2.09 5.79
3 12345 5.11 9.89
4 88552 4.01 8.79
NEED SHEET 1 to change to
A B C
2 12345 5.11 9.89
3 15874 4.22 10.99
4 11111 2.09 5.79
5 98745 5.33 9.95
6 88552 4.01 8.79
On a third sheet use these functions
column a ='sheet1'!a2
column b =if('sheet1'!b2='sheet2'!b2,'sheet2'!b2,'sheet1'!b2)
column c =if('sheet1'!c2='sheet2'!c2,'sheet2'!c2,'sheet1'!c2)
Copy sheet3 and paste the values into sheet1.
This should work unless column a does match. or if you need to do this dynamically. If column a doesn't match some vlookups can be thrown in.
I your data does match in column a your formulas could look something like this.
column a ='sheet1'!a2
column b =if(not(iserror(vlookup(a2,'sheet2'!a:c,2,false))),vlookup(a2,'sheet2'!a:c,2,false),vlookup(a2,'sheet1'!a:c,2,false))
column c =if(not(iserror(vlookup(a2,'sheet2'!a:c,3,false))),vlookup(a2,'sheet2'!a:c,3,false),vlookup(a2,'sheet1'!a:c,3,false))
this is too much to put in a comment so I'm putting it in answer.
The way I under stand is, since sheet1 has more data, you only want to be doing this comparison when sheet1 and 2 both have data on the row. so If sheet1 has data in rows 1 - 100, and sheet2 has data in rows 1 to 50, you only want to be doing this comparison for the first 50 rows in sheet1 right?
So, rather than copying and pasting formulas, what you can do is, in sheet1, find an unused column. go to the first row. in the formula box, type: "=if(" without the quotes. now, select the first cell to compare, according to your example you'd select sheet1, A2. then type "=" without quotes. then select the second cell you want to compare - in your example, sheet2, A2. then type "," without quotes. then select the cell from which you want the data if the first 2 cells are equal. in your example, sheet2 B2. then type "," without quotes, then select the cell with the data to use if the first 2 cells are not equal. in your example, sheet1 b2. then type ")" without the quotes.
so using your example, the function would look similar to how bigtree had it: =if('sheet1'!A2='sheet2'!A2,'sheet2'!b2,'sheet1'!b2)
so, this will compare sheet1 cell A2 with sheet2 A2 and if they are equal, the cell you put the formula in will the have the value of sheet2 b2, and if they are not equal, the cell with this formula will have the value of sheet1 B2. then, drag this formula down for however many rows you want, and the formula will adjust automatically for each row. you'll see the numbers increase. then, select the column with the formulas, right click and select copy, then right click and go to paste special, and click values. this will make it so the column contains only the values, not the formulas, now you can paste this data in column B sheet 1.
you can reuse this formula for whatever columns, just follow the steps.
HTH, good luck!

Resources