Create a unique list even if original list contains cells with ="" - excel

I have the following Excel spreadsheet:
A B
1 Original List Unique List
2 Product A Product A
3 Product A Product B
4 Product B Product C
5 =""
6 Product A
7 Product C
8 Product B
9 =""
10 Product C
In Column A I have list which contains several products multiple times. My goal is now to create a list of all unique items in Column B.
To achive this I used the formula from this post in Cells B2:B10:
B2:B10 =IFERROR(INDEX($A$2:$A$10,MATCH(SUM(COUNTIF(B$1:B1,$A$2:$A$10)),COUNTIF($A$2:$A$10,"<"&$A$2:$A$10),0)),"")
and I get the following result:
A B
1 Original List Unique List
2 Product A
3 Product A Product A
4 Product B Product B
5 ="" Product C
6 Product A
7 Product C
8 Product B
9 =""
10 Product C
This result comes pretty close to the list I want. The only issue is that the formula cannot handle the formula ="" which is in some cells in Column A. Instead of starting the list in Cell B2 it starts the list in Cell B3.
How do I have to mody the formula so it also works in case there are cells with ="" in the original list?

Could you use excel's built in 'Remove Duplicates' function?:
Range("$A$2:$A$10").RemoveDuplicates Columns:=1, Header:=xlNo

We can use a "helper" column. In C2 enter:
=IF(A2="","",IF(COUNTIF($A$2:A2,A2)>1,"",1+MAX($C$1:C1)))
and copy down. Column C assigns a simple sequential value to each item in column A from which data will be extracted. Then in B2 enter:
=IFERROR(INDEX($A$2:$A$10,MATCH(ROWS($1:1),$C$2:$C$10,0)),"")
and copy down:
Note:
This method uses normal formulas rather than array formulas.

You could use the Advanced Filter.
Use a Formula criteria such as =LEN(A5)>0 where A5 is the first cell with data. And then check the Unique Records Only in the Advanced Filter dialog. You can either filter in place, or to a new location

Related

Identify if list contains not unique values without countif in a helper column

A B C
1 Product A 1 Error
2 Product B 1
3 Product C 2
4 Product C 2
5 Product D 1
6 Product E 1
7
8
In the table above I want to identify if the values in Column A are unique.
If there is at least one value which is not unique Error should be displayed in Cell C1.
In order to achieve this I went with helper Column B and with the following formulas:
Column B `=COUNTIF($A$1:$A$6,A2)`
Cell C1 =`IF(COUNTA($A$1:$A$6)<SUM($B$1:$B$6),"Error","OK")`
All this works fine.
Now, I am wondering if there is also way to avoid the helper column.
Basically, a formula that goes through Column A and if it identfies at least one not-unique value it should display Error in Cell C1.
use:
=IF(MAX(COUNTIF($A$1:$A$6,$A$1:$A$6))>1,"Error","OK")
This is an array formula and depending on one's version will require the confirmation of Ctrl-Shift-Enter instead of Enter when exiting edit mode.
If one has the dynamic formula UNIQUE() then:
=IF(COUNTA(UNIQUE($A$1:$A$6))<>COUNTA($A$1:$A$6),"Error","OK")
As a normal formula.
Another formula, that will work in Conditional formatting:
=SUMPRODUCT(--(MATCH($A$1:$A$6,A:A,0)<>ROW($A$1:$A$6)))>0

Get the column number of a search criteria in a defined range

I have the following Excel spreadsheet:
A B C D E F G H
1 Search Criteria: Prod.D
2 Column: 4
3 Prod.A Prod.B Prod.C Prod.D Prod.E
4
5
In Range D3:H4 I have Product A to Product E listed.
Now, I want to achieve that when I put a product name into Cell C1 I will get back the Column Number of the product in the range.
In the example above I want to search for Prod.D within the Range D3:H4 and therefore the result in Cell C2 should be 4 since the search criteria appears in the fourth column within the defined range.
What formula do I need to achieve this?
Try this formula in cell C2:
=MATCH(C1,D3:H3,0)

Formula to Return Text in the Row of Largest Number

Column A Has Text & Columns B, C & D contain numbers.
For Ex.)
A... …B C D
John 4 6 2
Dave 4 6 4
Mike 4 5 1
Bill 2 5 9
I would like a cell to return the name in column A that has the Largest Number in Column B. And if there are similar numbers, go to the next column and determine which is highest, and if that is tied go to the next column and so on.
Any help would be appreciated.
We can de-conflict ties.In E1 enter:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))
and copy down. Then in another cell enter:
=INDEX(A:A,MATCH(MAX(E:E),E:E,0))
EDIT#1
This is only good for 3 columns of numbers, but it is very easy to add additional de-confliction terms if necessary:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))+E1/(1000*MAX(E:E))
For an expandable number of rows/columns, use a helper row with the same number of columns as number columns in your data. The formulas below reference the following image (the data are in A1:G7):
B9-->=MAX(B1:B7)
C9 (fill over the remaining columns to G9)-->
=MAX(IF(MMULT(--($B1:B7=$B9:B9),--(ROW(INDIRECT("1:"&COLUMNS($B9:B9)))>0))=COLUMNS($B9:B9),C1:C7))
The following formula will give the answer (shown in A9 above):
=INDEX(A1:A7,MATCH(TRUE,(MMULT(--($B1:G7=$B9:G9),--(ROW(INDIRECT("1:"&COLUMNS($B9:G9)))>0))=COLUMNS($B9:G9)),0))
UPDATE WITH ALTERNATIVE METHOD
Using a helper column instead, again referencing the image below (the data are in A1:G7):
I1 (fill down to I7)-->
=SUM(--(MMULT(SIGN(B1:G1-$B$1:$G$7)*2^(COLUMN(G1)-COLUMN(A1:F1)),--(ROW(INDIRECT("1:"&COLUMNS(B1:G1)))>0))>0))
The following formula will give the answer (shown in J1 above):
=INDEX(A1:A7,MATCH(MAX(I1:I7),I1:I7,))
As a bonus, notice that the helper column corresponds to the order that you would get from sorting the data by each column left-to-right. In other words, you could use the helper column to perform a formula-based multi-column sort on strictly numeric data. For the last image, entering the following array formula into a range with the same dimensions as A1:G7 gives a descending sort on columns B through G:
=IF(A1:A7=A1:A7,INDEX(A1:G7,MATCH(ROW(A7)-ROW(A1:A7),I1:I7,0),))

List items based on criterias in two different columns

I have the following Excel spreadsheet:
A B C
1 Product Sales List
2 Product A 500 Product A
3 Product B Product C
4 Product C 400 Product D
5 Product E
6 ="" Product F
7 Product D 600 Product H
8 Product E 550
9 =""
10 Product F 200
11 Product G =""
12 Product H 800
In Column A and Column B different products with their sales are listed. As you can see it can either happen that there are empty cells or cells with ="" in both Column A or Column B.
In Column C I want to achieve now that only the products which do NOT have an empty cells or cells with ="" in Column A or Column B are inlcuded in the list.
I could already make it work for Column A with this formula:
={INDEX($A$2:$A$100,SMALL(IF(LEN($A$2:$A$100)=0,"",ROW($A$2:$A$100)-MIN(ROW($A$2:$A$100))+1),ROW(A1)))}
What do I have to change in this formula to also exclude the products wich have an empty cell or a cell ="" in Column B from my list in Column C?
When you have worked it out for Column A, it is very simple to do for B:
Each cell in Column D has the appropriate function: (Example for D2)
=VLOOKUP(D2, $A:$B, 2, 0)
NOTE: This assumes you don't have repeated values in Column A
doesn't have to be an array formula. use this formula in C instead.
=IF(AND(A:2<>"",B:2<>""),A:2,"")
Then autofill the formula. Then sort column C to get all product list.
or pivot the range by column C in row box to get the distinct product list in case A has duplicate products.

Fill empty cells with values from a list in another column

I have the following Excel spreasheet:
A B C
1 =IF(B1<>"",B1;OFFSET(B1,-1,0)) CompanyA
2 =IF(B2<>"",B2;OFFSET(B2,-1,0))
3
4 CompanyB
5 CompanyC
6
7 CompanyD
In column B I have a list of different companies and it might happen that they are empty rows (in this case row2, row3 or row6) between the companies.
In column A I want to achieve that the empty rows are filled with the company names so in the end the spreadsheet looks like this:
A B C
1 Company A CompanyA
2 Company A
3 Company A
4 Company B CompanyB
5 Company C CompanyC
6 Company C
7 Company D CompanyD
I tried to use the If-formula with the offset in column A but it only works when there is not more than one empty row so it only works for CompanyB,C and D but not for company A.
Do you have any idea which formula I have to use in column A to solve this issue?
Pls refer the snap below
In A2 apply the below formula and drag down
=IF(B2<>"",B2,A1)
EDIT #1: Another method if data starts with row 1
if the data starts with B1 then apply the below formula in A1 and drag down
=IF(B1<>"",B1,IF(ROW()=1,B1,OFFSET(A1,-1,0)))
Provided the first cell, say B2, is not empty try with:=B2 in cell A2 and =IF(B3<>"";B3;A2)in cell A3 and fill down.

Resources