Rename duplicates with random alphabets in a column - Excel - excel

I have a list of 500 names in column A.
1 name1
2 name2
3 name3
4 name1
5 name2
6 name3
7 name1
8 name2
9 name3
..
And i need to add a prefix or suffix alphabets to the duplicates. And I should get
1 name1
2 a.name1
3 b.name1
4 name2
5 a.name2
6 b.name2
7 name3
8 a.name3
9 b.name3
..
And i have selected duplicate values
select column -> conditional formatting -> Highlight Cell Rules -> Duplicate Values
How to rename duplicate values with random alphabets prefix or suffix

If you prefer to use a non-random prefix that just contains the next letter, you could do something like this starting in C2:-
=IF(B2=B1,CHAR(96+COUNTIF(B$1:B1,B2))&"."&B1,B2)
I'm assuming that the names are sorted, have a heading and are in column B.
If you didn't want to sort them, this would still work with a modification:-
=IF(COUNTIF(A$1:A1,A2)>0,CHAR(96+COUNTIF(A$1:A1,A2))&"."&A2,A2)
I'm assuming that the unsorted names are in column A, with a header.

Without using VBA - you can't edit the cells themselves, except using formatting.
You could however, use a helper column and use a formula on these lines to accomplish this:
=IF(A2=A1,CHOOSE(RANDBETWEEN(1,26),"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z")&" "&A2,A2)
Bear in mind that because this is random, there is a small chance of two consecutive letters - so you may need to use another formula to check for this and make a small amount of manual tweaks.

Related

Excel table Lookup values

I have a table-1 like this:
NAMES ID
John 1
Bill 2
May 1
Silvia 1
Sam 3
Oren 2
Another table-2:
ID_To_Compare name1 name2 name3
1
2
3
I would like to have in table-2 function that gets result like this, according to ID_To_Compare (seeks it in table-1):
ID_To_Compare name1 name2 name3
1 John May Silvia
2 Bill Oren
3 Sam
An Excel lookup looks like this;
=VLOOKUP(I7;Sheet1!$A$2:$F$250;2;FALSE)
The first part (I7 in this case) is the value of the key to find.
The second part (Sheet1!$A$2:$F$250 in this case) is the range to search in.
The third part (2 in this case) is the column index of the queried range from which the value should be read.
The last boolean tells whether or not it is a range lookup (in this case we're after a single value).
With your sample data:
Formula in cell B10:
=IFERROR(INDEX($A$1:$A$7,SMALL(IF($B$1:$B$7=$A10,ROW($A$1:$A$7),""),COLUMN(A1))),"")
Confirm through CtrlShiftEnter
Drag down and right...

Lookup Function Excel

I am working on a lookup function and I cant seem to make it work. I am looking up a value from one worksheet into another. The issue I am having is that some names in the excel sheet iI am looking up are not spaced at the same as the other sheet.
For example instead of John Davis, the lookup sheet might have the name as JohnDavis. Or Peter Lee Thomas might be Peter LeeThomas. So my looking function is failing because of this.
=IF(B2="AD Non Chargeable","Internal",INDEX(Sheet3!B:B,MATCH('Raw Data'!B2,Sheet3!A:A,0)))
Can you please advice on the best way around this? My Lookup sheet is Sheet3
Okay, if for example your data looked like this:
A B C D
Some Text 1 2 SomeText3
Som e Text 2 3 Some Text 2
So meText 3 4 SomeTex t1
Lookup formula in column D would be:
=INDEX($B$1:$B$3,MATCH(SUBSTITUTE(C1," ",""),SUBSTITUTE($A$1:$A$3," ",""),0))
Make sure to apply this formula with Ctrl + Shift + Enter.
The result will look as expected:
A B C D
Some Text 1 2 SomeText3 4
Som e Text 2 3 Some Text 2 3
So meText 3 4 SomeTex t1 2
One solution would be to create another column Sheet3, in this example B, to remove all spaces, like this:
In cell B2 (and copied down): =substitute(A2,"","")
Then alter your lookup to alter its data similarly and to search in this space eliminated row B:
=IF(B2="AD Non Chargeable","Internal",INDEX(Sheet3!B:B,MATCH(substitute('Raw Data'!B2," ",""),Sheet3!A:A,0)))

Excel function for SELECT DISTINCT.. WHERE

I am trying to filter data in an Excel sheet using functions based on multiple columns. For example, if column B has '*ABC*', I want to count the number of unique values in column A.
A B
--- ---
1 xyz
1 abc
2 ABCD
3 AB
4 ABCE
4 qwe
4 ABC
5 xyzABC
For the above example, I am expecting the answer 3, since the number of unique values in A matching '*ABC*' are 2,4 and 5 => 3 unique values.
Index Match only returns the first result and I am not able to figure out how to use Countifs to join both these conditions - unique and wildcard match.
As an Array Formula:
=SUM(IF(ISNUMBER(SEARCH("ABC",B1:B8)),1/COUNTIFS(A1:A8,A1:A8,B1:B8,"*ABC*")))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. If done correctly then Excel will put {} around the formula.

Find duplicates with a suffix in excel and keep results

I have a spreadsheet with a list of items in one column (A) and in column C shows the total sold. I'm trying to find all the items within column A.
The issue is, some items are the same, only they have a suffix, mostly separated by a -. The values in column C would be different as well.
Example:
ABC = 5
ABC-123 = 3
ABC-543 = 2
I'm looking to identify only 123 and then combine all the values, so that it will show ABC and 10 as the total.
I've looked around how to remove the duplicate suffix, but have so far failed to find a method when trying to add the total values.
Many thanks
do you mean the data you have looks like this:
column A column B column C
ABC 5
ABC-123 3
ABC-543 2
if so, you can select column A then go to data then text to columns then delimited select other by putting - sign, next and finish.
result must be:
column A column B column C
ABC 5
ABC 123 3
ABC 543 2
then you can =sumifs(C:C;A:A;"ABC") (keep in mind that column B must be empty)
if you have ABC-123 = 3 in the same cell as a text, then you can do:
=IF(SEARCH("ABC";F3);RIGHT(F3;LEN(F3)-FIND("=";F3)-1);"")
where F3 is equal to ABC-123 = 3 The formula above searches fo ABC and gives you a value after = sign, no matter how long this value is. If there is no ABC it will return an error.
if there is no need to look for ABC then just use:
=RIGHT(F3;LEN(F3)-FIND("=";F3)-1)
I hope this helps. I cannot comment, so ask if you have questions.
Best - AB

Merge unique values if another cell matches

Merge all unique values if another cell matches. I already know how to merge cells but now some information is double. So what I would like to achieve is the following:
if column A has the same name, then all values given in column B for
that name must be given only ONCE in a new column.
My data has a row names and a row mode, for example (Row 1 is header)
A B
2 Brenda a
3 Brenda a
4 Joey a
5 Joey b
So I want:
E
2 a
3
4 a,b
5
I already did merge the modes in column 3:
=IF(A1<>A2;B2;C1&","&B2)
So I get in this example:
C
2 a
3 a,a
4 a
5 a,b
Then, I already did that only the first record get the additional modes in column 4:
=IF(A1=A2;"";INDEX(Sheet1!$C:$C;COUNTIF(Sheet1!$A:$A;$A2)+MATCH($A2;Sheet1!$A:$A;0) -1))
So I get in this example
D
2 a,a
3
4 a,b
5
Now I need a column that only uniques values are given for each name. So in this example:
E
2 a
3
4 a,b
5
If I am understanding how your data is structured, try this:
Add a new column, say column G for ease of explanation, that concatenates the name and mode in each row. So, cell G2="Brendaa", G3="Brendaa", G4="Joeya", G5="Joeyb", etc.
In your merge step you will test whether the current value in the cell for this column matches any previous values in the column: If no, you do the merge; if yes, you don't.
Your merge formula would change to something like the following:
=IF(A1<>A2,B2,IF(ISERROR(VLOOKUP(G2,G$1:G1,1,0)),C1&","&B2,""))
Then you would the next step as before.

Resources