Sheet 1 goes like this:
Sheet 2 should be like this:
ITEMS QUANTITIES
APPLE 4
GUAVA 2
Sorry for writing the spreadsheet in here, as I'm not allowed to include more than 1 image yet.
Suppose you have the following named ranges:
ITEMS being the data in ITEMS column on your Sheet1;
QUANTITY being the data in QUANTITY column on your Sheet1.
Enter the following formula in Cell D2 on your Sheet2:
=IFERROR(INDEX(ITEMS,MATCH(0,COUNTIF($D$1:D1,ITEMS),0)),"")
Please note it is an array formula which requires you to press Ctrl+Shift+Enter upon finishing the formula in the formula bar.
Drag it down until there is no more items showing up.
Then you can enter the following formula in Cell E2 on your Sheet2 and drag it down:
=SUMIF(ITEMS,D2,QUANTITY)
As you can see from the above screenshot, there may be some empty cells in Column D as I used IFERROR to return blank cells if there is no more distinct item. The corresponding quantity will be 0 consequently. You can choose to delete them or hide them on your worksheet.
By the way I am not sure why Pivot Table is out of the picture as it is actually a faster and easier approach than formula and you do not have to worry about the blank cells returned by the formula if the number of unique items is uncertain. All you need to do is to highlight the source data, insert a pivot table, and put the ITEM in Rows and QUANTITY in Values field.
EDIT: Update to also extract unique distinct values:
Enter this formula in cell A2 of Sheet2:
=IFERROR(LOOKUP(2,1/(COUNTIF($A$1:A1,Sheet1!$A$2:$A$300)=0),Sheet1!$A$2:$A$300), "")
Change 300 to the actual last row of your data and copy that formula down until it returns empty cells.
Then just use a regular SUMIF in cell B2 of Sheet2:
=SUMIF(Sheet1!A2:A300, A2, Sheet1!B2:B10)
Then, type whatever fruit you're looking for incell A2 of Sheet2. Continue like this in the following rows for all the fruits you need.
Related
I have 2 worksheets that are connected through a unique ID column shared by the two sheets. I made the two below spreadsheets to test the formula as my actual data is quite long.
I am using the INDEX and MATCH formulas to pull a value from Sheet2 to populate a cell in Sheet1 if the ID value found in the row of Sheet1 matches an ID value found in Sheet2. I can accomplish this with the following formula
=INDEX(Sheet2!B:B,MATCH(Sheet1!A:A,Sheet2!A:A,0))
However, what I am actually after is for the INDEX to SUM of all values in the WGT column on Sheet2 on Sheet1 when there is a MATCH between the two ID columns (I know with this test data there are two instances of every ID on Sheet2). The above formula only INDEXes the first WGT value when a MATCH is found between the ID columns.
I am pretty sure I am supposed to use some variation of the SUMIF formula but I can't seem to get one that works at all. Thanks for any help!
The syntax for Sumif is Sumif(criteria range, criterion, [sum range]). So, you would need in Sheet2, cell B2
=sumif(Sheet1!A:A,Sheet2!A2,Sheet1!B:B)
In words: generate a sum or all numbers in column B of Sheet1, where column A of Sheet1 equals the value of cell A2 on Sheet2.
Copy that down.
Alternatively, you could click in the data of Sheet1 and insert a pivot table. Drag the ID field into the Rows area and the WGT field into the Values. Just a few clicks, no formula.
Another option to use Sum + Index function
In sheet1, B2 array formula copied down :
=SUM(INDEX(Sheet2!B:B,N(IF(1,(Sheet2!A:A=A2)*ROW(Sheet2!A:A)))))
This is an array formula and needs to be confirmed by pressing with Ctl + Shift + Enter.
I have a work sheet in which there are several cells with a specific entry - let's say "A". These are not all in the same rows/columns. After each cell is a date.
I need to count the number of cells containing "A" which also have a specific date in the cell immediately to its right. I've tried combinations of Countifs and Indirect, with no success. How can I achieve this?
This counts the number of times that there is A in column A and 1 in column B
=SUMPRODUCT(($A$1:$A$5="A")*($B$1:$B$5=1))
This outputs in cell D1
Not too difficult.
I have created a sample sheet with 8 rows and 5 columns of data.
See below, the formula in cell C12 counts the number of occurrences where the a cell with a date of October 31, 2017 is directly to the right of a cell that contains the text A.
If you want more info as to how this works, read on:
When searching for cells that contain A, you don't search in the last column of the data (in this case, column E) because it is impossible for a column to the right to have any date in it. This is why a portion of the formula says A1:D8="A" instead of A1:E8="A". This is the same reasoning why we start searching for a date in column B rather than column A in the formula.
You can achieve this with a helper row. Add additional row on top of your Worksheet. In cell "A1" enter formula below.
=COUNTIFS(A2:A2000,"A",B2:B2000,"YourDate")
Drag this formula to the rightmost of where you have data, then simply sum all values returned by formula.
Sorry if the title is off, but I have no way of making this short.
I have an excel file with 2 sheets: Sheet1 has the first column filled with data, but in a random pattern (ex: 6 consecutive cells are with data, 6 are without, other of the following alternate; basically there is no way of knowing if the next cell has data or not). I want to copy the first column from Sheet1 into Sheet2 without any blank cells or duplicate ones (the order of the data can be maintained or be changed as the result of the formula).
Can this be done without any coding?
Assuming your Sheet1 is as follows
Then in Cell A2 of Sheet2 enter the following formula
=IFERROR(INDEX(Sheet1!A$2:A$50,SMALL(INDEX(NOT(ISBLANK(Sheet1!$A$2:$A$50))*ROW($A$1:$A$49),0),COUNTBLANK(Sheet1!$A$2:$A$50)+ROW($A1))),"")
Drag/Copy down as required. Change range in formula as needed. See image for reference.
EDIT :
To get unique values from Column A of Sheet2 enter below formula in Cell B2 of Sheet2
=IFERROR(INDEX($A$2:$A$20,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$20),0,0),0)),"")
I'm trying to create a summarize information for all of the supplier our company have. I have my sheet1 as my main database where in all our suppliers are listed. I would like to create several additional sheets which will contain each specific nature of business of the suppliers.
What I would like to happen is, given that my sheet2 is for the suppliers who specialize in "PRINTING", sheet3 is for those who specialize in "I.T EQUIPMENT". Whenever I add a supplier on my sheet1, it will automatically be added on my sheet2 or 3 as well if it matches its specialty. Please help!
Thank you in advance!
Considering your Sheet1 is Master Sheet where names of all Suppliers and their Specialties are listed in Column A and Column B respectively.
If in Sheet2 you want to list down the all Suppliers with Printing as specialty, write following formula in Cell A2 of Sheet2
=IFERROR(INDEX(Sheet1!A$2:A$25,SMALL(IF(Sheet1!B$2:B$25="Printing",ROW(A$2:A$25)-ROW(A$2)+1),ROWS(A$2:A2))),"")
and drag/copy it down as required. This is an array formula so enter this formula by pressing Ctrl+Shift+Enter.
Likewise, if in Sheet3 you want to list down all Suppliers with IT Equipment as specialty, write following formula in Cell A2 of Sheet3
=IFERROR(INDEX(Sheet1!A$2:A$25,SMALL(IF(Sheet1!B$2:B$25="IT Equipment",ROW(A$2:A$25)-ROW(A$2)+1),ROWS(A$2:A2))),"")
and drag/copy it down as required. Again, this is an array formula so enter this formula by pressing Ctrl+Shift+Enter.
To automatically update the list in Sheet2 and Sheet3, you'll have to take care of two things:
1. Range in the above formula is row 2 to row 25, you'll have to enter the range till the row you think your list could be extended. For example if your list will not get past the row 1000 then formula for Printing in Sheet2 becomes
=IFERROR(INDEX(Sheet1!A$2:A$1000,SMALL(IF(Sheet1!B$2:B$100="Printing",ROW(A$2:A$1000)-ROW(A$2)+1),ROWS(A$2:A2))),"")
2. You'll have to drag/copy down this formula in Sheet2 and Sheet3 till the row you think the list could extend based on the Sheet1 data.
You can even use just one formula for all the sheets as follows:
=IFERROR(INDEX(Sheet1!A$2:A$25,SMALL(IF(Sheet1!B$2:B$25=$C$1,ROW(A$2:A$25)-ROW(A$2)+1),ROWS(A$2:A2))),"")
where Cell C1 of each sheet will have the specialty name.
See image for reference
I've been working on a excel problem, that I need to find an answer for I'll explain it below.
I've Table01 with the Columns :
Group No
Name
Price
I've Table02 with the columns:
Group No
City
Code
I've merged two tables of Table01 & Table02 as shown in the Image03 , But without order.
But,as you see Group No Column is similar in both tables.
What I need is to get the matching rows of Table01 & 02 considering 'Group No' Column.
The Final result is to be seen as the final image.
Is there a way to do this with excel functions ?
Thank You!
Put the table in the second image on Sheet2, columns D to F.
In Sheet1, cell D2 use the formula
=iferror(vlookup($A2,Sheet2!$D$1:$F$100,column(A1),false),"")
copy across and down.
Edit: here is a picture. The data is in two sheets. On Sheet1, enter the formula into cell D2. Then copy the formula across to F2 and then down as many rows as you need.
Teylyn's answer worked great for me, but I had to modify it a bit to get proper results. I want to provide an extended explanation for whoever would need it.
My setup was as follows:
Sheet1: full data of 2014
Sheet2: updated rows for 2015 in A1:D50,
sorted by first column
Sheet3: merged rows
My data does not have a header row
I put the following formula in cell A1 of Sheet3:
=iferror(vlookup(Sheet1!A$1;Sheet2!$A$1:$D$50;column(A1);false);Sheet1!A1)
Read this as follows: Take the value of the first column in Sheet1 (old data). Look up in Sheet2 (updated rows). If present, output the value from the indicated column in Sheet2. On error, output the value for the current column of Sheet1.
Notes:
In my version of the formula, ";" is used as parameter separator instead of ",". That is because I am located in Europe and we use the "," as decimal separator. Change ";" back to "," if you live in a country where "." is the decimal separator.
A$1: means always take column 1 when copying the formula to a cell in a different column. $A$1 means: always take the exact cell A1, even when copying the formula to a different row or column.
After pasting the formula in A1, I extended the range to columns B, C, etc., until the full width of my table was reached. Because of the $-signs used, this gives the following formula's in cells B1, C1, etc.:
=IFERROR(VLOOKUP('Sheet1'!$A1;'Sheet2'!$A$1:$D$50;COLUMN(B1);FALSE);'Sheet1'!B1)
=IFERROR(VLOOKUP('Sheet1'!$A1;'Sheet2'!$A$1:$D$50;COLUMN(C1);FALSE);'Sheet1'!C1)
and so forth. Note that the lookup is still done in the first column. This is because VLOOKUP needs the lookup data to be sorted on the column where the lookup is done. The output column is however the column where the formula is pasted.
Next, select a rectangle in Sheet 3 starting at A1 and having the size of the data in Sheet1 (same number of rows and columns). Press Ctrl-D to copy the formulas of the first row to all selected cells.
Cells A2, A3, etc. will get these formulas:
=IFERROR(VLOOKUP('Sheet1'!$A2;'Sheet2'!$A$1:$D$50;COLUMN(A2);FALSE);'Sheet1'!A2)
=IFERROR(VLOOKUP('Sheet1'!$A3;'Sheet2'!$A$1:$D$50;COLUMN(A3);FALSE);'Sheet1'!A3)
Because of the use of $-signs, the lookup area is constant, but input data is used from the current row.