Excel Formula To LookUp - excel-formula

I have two sheets. Sheet1 has BrandName and the Price.
Sheet2 sheet has same info, BrandName and Price. But this sheet has multiple Prices for same Brand.
I want a formula to lookup the closest price for a brand from Sheet2 to Sheet1.
Very Much similar to This
Sheet1
Brand-------Price------Closest Price
A--------------100 --------?
B--------------200---------?
Sheet2
Brand-------Price
A--------------100
A--------------105
B--------------201
B--------------210
B--------------205

The formula in your Sheet1!C2 could be
{=INDEX(Sheet2!B:B,MIN(IF(IF(Sheet2!A:A=A2,ABS(Sheet2!B:B-B2))=MIN(IF(Sheet2!A:A=A2,ABS(Sheet2!B:B-B2))),ROW(Sheet2!A:A))))}
This is an array formula. Input the formula into the cell without the curly brackets and press [Ctrl]+[Shift]+[Enter] to finish.
Array formulas are poor in performance. So if it is slow in calculation, shrink the ranges related to Sheet2. Try Sheet2!$A$1:$A$10000 and Sheet2!$B$1:$B$10000 for example.

Related

Cumulative Amounts of Dupe-only Items in a Resultant Sheet

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.

SUMPRODUCT on all sheets with sheet multiplier

I have multiple sheets that have the same layout but have different products and quantities on each sheet.
Then I have a different sheet that I'm using to total all the other sheets quantities per product I'm using this formula
=SUMPRODUCT(SUMIF(INDIRECT("'"&D$8:D$10&"'!B3:B6"),B3,INDIRECT("'"&D$8:D$10&"'!A3:A6"))) Which works fine.
How can I sum all the product quantities from the same sheet more than once, For example if I add the number of times I want to multiply the sheet In column E next to each sheet name and I put a qty of 2 in E8 it would then double the quantity for that sheet well still summing all the other sheets.
You can use Named Ranges for this. Give the Cell "E8" a name - "Takeoff1_Multiplier" and in the Sheet Takeoff1, go to cell "A3" and in the formula bar enter
the formula =1*Takeoff1_Multiplier.
Now, when you change the value in "E8", the value in "A3" will be multiplied.
If you don't want to use a formula in the Column A in the Takeoff1 sheet, use the formula in column c as =A3*Takeoff1_Multiplier and drag this formula for all the rows.
Resources:
Named Range: https://support.office.com/en-us/article/define-and-use-names-in-formulas-4d0f13ac-53b7-422e-afd2-abd7ff379c64
=SUMPRODUCT($E8:$10*SUMIF(INDIRECT("'"&D$8:D$10&"'!B3:B6"),B3,INDIRECT("'"&D$8:D$10&"'!A3:A6")))
or
=SUMPRODUCT($E8:$10,SUMIF(INDIRECT("'"&D$8:D$10&"'!B3:B6"),B3,INDIRECT("'"&D$8:D$10&"'!A3:A6")))
Both methods should work. Basically you are weighting the results of each sumif sheet result by the corresponding number n your table before taking the final sum/grand total.

Cleaning a column from one sheet into another

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)),"")

Range row number reference from another cell in Excel

Edited: So I made the question more complicated. If I would like to do a 'what if ' analysis which requires to be able to refer the last row to sum from another cell to the sumif formula. How can I do that?
Just drop the row numbers from your formula and use the entire columns:
=SUMIF(A:A,">4",B:B)
The beauty is that SUMIF will disregard non-nmeric rows anyway.
To sum up and stop at a certiain row, you can use SUMIFS with ROW:
=SUMIFS(B:B,A:A,">4",C:C,"<" & D2)
Where D2 holds the row number using the formula =ROW(<CELL>), i.e: =ROW(A2) in cell C2:

Excel categorize list transfer

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

Resources