Creating unique ID numbers for duplicate Excel rows - excel

I have an Excel spreadsheet with multiple columns. I'd like to automatically add unique ID numbers (starting in cell A2) to duplicate values in column D (starting at D2). Any way to make the spreadsheet look like below? Thanks.
Column A Column D
1 3
1 3
2 Bard
2 Bard
3 4ton
3 4ton
3 4ton

In A1 enter 1
In A2 enter:
=IF(D1=D2,A1,A1+1)
and copy down.

It's not clear on whether your data table has column header labels or not but this formula should not make a difference beyond having to pre-populate A1 if there is no column header label.
In A2 use this formula,
=IFERROR(INDEX(A$1:A1, MATCH(D2, D$1:D1, 0)), MAX(A$1:A1)+1)
Fill down as necessary. Your results should resemble the following.
        
While your column D was sorted, that is not a requirement with this formula.

Related

Transpose single column to array of unique rows

I'm trying to get a list of values that contain duplicates into unique rows.
Column A
Cell 1
Cell 2
Cell 3
Cell 1
Cell 2
Cell 3
Cell 1
Cell 2
Column A
Column B
Column C
Cell 1
Cell 1
Cell 1
Cell 2
Cell 2
Cell 2
Cell 3
Cell 3
I've tried using
=TRANSPOSE(UNIQUE(A1:A3,TRUE,TRUE))
But any combination of the formula removes the duplicates and I want to maintain them.
with MakeArray:
=LET(
rng,A1:A8,
u,UNIQUE(rng),
MAKEARRAY(
ROWS(u),
MAX(COUNTIF(A1:A8,u)),
LAMBDA(a,b,
IF(COUNTIF(A1:A8,INDEX(SORTBY(u,COUNTIF(A1:A8,u),-1),a))>=b,
INDEX(SORTBY(u,COUNTIF(A1:A8,u),-1),a),
""))))
This will expand automatically to any number. It will also put the ones with the most duplicates at the top so it is an inverted pyramid:
Alternatively, you can try:
Formula in C1:
=IFERROR(DROP(REDUCE(0,UNIQUE(TOCOL(A:A,1)),LAMBDA(x,y,VSTACK(x,EXPAND(y,1,COUNTIF(A:A,y),y)))),1),"")
Or, with a build-in sort function:
=SORT(IFERROR(DROP(REDUCE(0,UNIQUE(TOCOL(A:A,1)),LAMBDA(x,y,VSTACK(x,EXPAND(y,1,COUNTIF(A:A,y),y)))),1),""),1)

Excel: How do I efficiently condition a cell so that I can identify a cell with observation counts less than a certain number?

Basically I wanted to only extract the top 2 rows for every Entry #, but if the Entry # does not have 2 rows it is not used.
I tried IF statements and eliminating blanks and whatnot, but if this is a large data I would not be able to handle it.
If you don't mind adding a few columns, here's one method. Arrange how you wish.
Column's B and F are your original data.
Column C, in cell C2, input your first value manually (1 in this case).
Then here's the formula for Cell C3:
=IF(ISBLANK(B3),C2,B3)
Cell D2 formula:
=IF(C2=C1,D1+1,1)
Cell E2 formula:
=IF(COUNTIF(C:C,C2)>1,"Yes","No")
Drag down your formulas.
Then you can filter on column E for YES, and filter on column D for 1 & 2.

Combining data in excel

Dears,
I have 4 columns in excel.
Each row have two values but also it is mapped to another row.
I'd like to sum the values from these the rows that are mapped and delete the extra rows.
Example attached: Row A has two values but also mapped to Row C. I want to add the values in Row A with the ones in Row C and keep Row A and delete Row C
Is it possible to use formulas instead of VBA as I don't have experience in VBA?
Please advise.
Assuming your Keyword data starts with A2 and Value 1 starts with B2 and Value 2 starts with C2. (Please refer the snap below)
Apply the below formula in H2 for Value 1 summing and drag down
=IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE))
Apply the below formula in I2 for Value 2 summing and drag down
=IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE))
EDIT #1 If G value does not contain in Table 1 then apply the below formula
in H2
=IF(ISERROR(IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE))),"Not Found in Table",IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,2,FALSE),VLOOKUP(G2,$A$2:$D$4,2,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,2,FALSE)))
in I2
=IF(ISERROR(IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE))),"Not Found in Table",IF(VLOOKUP(G2,$A$2:$D$4,4,FALSE)=0,VLOOKUP(G2,$A$2:$D$4,3,FALSE),VLOOKUP(G2,$A$2:$D$4,3,FALSE)+VLOOKUP(VLOOKUP(G2,$A$2:$D$4,4,FALSE),$A$2:$D$4,3,FALSE)))

Auto number a column in Excel, and include ranges when specified by another column

Let's say I have two columns in Excel. I need to auto number the values in Column A, but some of those values will be dependent on Column B. For the dependent values, I need a solution that will input a range of numbers based on the value in column B. So, if cell B1 has a 3 in it, then when I auto number column A, I'd need cell A1 to wind up being 1-3.
Here's another example. If Column B looked like this:
Column B
[empty cell]
2
3
[empty cell]
Then I'd want the result to look like this after filling in column A:
Column A Column B
1
2-3 2
4-6 3
7
Is there an easy way to do this when writing a formula for Column A? Or, is there a better way altogether to auto number a column in Excel while optionally including number ranges in some of the cells?
This seems to work:
In A2 enter:
=SUM(B$1:B1)+COUNTBLANK(B$1:B1) & IF(B2<>"","-" & SUM(B$2:B2)+COUNTBLANK(B$2:B2),"")
and fill down

how to search for two consecutive cells that have 2 different values?

Because I am working with a very large sheet of excel and i need to find in a specific column the last 1 before changing to 0.
is there a way to search for that ?
how to search for two consecutive cells that have 2 different values ?
If your values are in column A, put into B2:
= A2 = A1
Copy B2 and paste to the rest of column B, from B3 to next to the last value in column A.
Search column B for FALSE.

Resources