I have column A containing number ID. Each row in column A is Unique.
I have column B containing City names. Each row In column B is unique.
I have column C with duplicated city names from Column B. Duplications are random. One city is duplicated 2 times and another 10 times and so on.
What I would like to achieve is to assign the number ID from column A to duplicates in column C. Each different duplicate should have number Id in a form A1+1.
Notice that Alexander in Column D has value from A2, along with all duplicates. Alma is next with ID 499. Those are manual entries of course.
Can anyone provide a formula to automate this?
I'm using Google Spreadsheets..
You would use INDEX/MATCH, put this in D2 and copy down:
=INDEX(A:A,MATCH(C2,B:B,0))
try this:
Clear data from column D.
Paste ArrayFormula into cell D2.
Here's the formula:
=ARRAYFORMULA(VLOOKUP(OFFSET(C2,,,COUNTA(C2:C)),{B2:B,A2:A},2,0))
I think I had to insert a column A with same values as Column C in order to get Vlookup to work, as I believe it indexes off of the 1st column always.
Related
I have two large columns.
Column A contains 100,000 different numbers/rows. Column B contains 100,210 numbers/rows. They have the same numbers except column B has 210 extra rows. I need to be able get the values of that extra 210 rows.
The issue im having is that the numbers in these rows are not unique.
For example,
Column A contains the following numbers: 2,1,3,4,5,5,6,7
Column B contains the following numbers: 1,2,3,4,5,5,5,5,6,6,7,8
I want the outcome result to be: 5,5,6,8
I can't seem to wrap my head around a way to do this.
I have the two columns in a text file that im importing into excel. If there are better ways to do it outside of excel, I am open to it too.
With the Dynamic Array formula Filter:
=FILTER(B1:B12,COUNTIF(OFFSET(B1,0,,SEQUENCE(ROWS(B1:B12))),B1:B12)>COUNTIF(A:A,B1:B12))
Without FILTER:
Put this in the first cell and copy down:
=IFERROR(INDEX(B:B,AGGREGATE(15,7,ROW(B1:B12)/(COUNTIF(OFFSET(B1,0,,ROW(INDEX($ZZ:$ZZ,1):INDEX($ZZ:$ZZ,ROWS(B1:B12)))),B1:B12)>COUNTIF(A:A,B1:B12)),ROW($ZZ1))),"")
Try to follow these steps, supposing that Column A has less values than the Column B and the rows start at 1:
A. Create Column C.
In the cell C1 place the function: =COUNTIF(A:A;B1)
Copy this function to the rest of cells, for all items of Column B. So, cell C2 will have the function =COUNTIF(A:A;B2) and so on.
B. Create column D.
In the cell D1 place the function: =COUNTIF($B1:$B1;B1)
Copy this function to the rest of cells, for all items of Column B. So, cell D2 will have the function =COUNTIF($B$1:$B2;B2) and so on.
C. Create column E.
In the cell E1 place the function: =IF(D1<=C1,"Exists","Missing")
Copy this function to the rest of cells, for all items of Column B. So, cell E2 will have the function =IF(D2<=C2,"Exists","Missing") and so on.
D. Filter to show only the rows that Column E values are "Missing".
Of course you can combine all above 3 columns to one (e.g. in Column F), so these cells will have the functions:
F1: =IF(COUNTIF($B$1:$B1,B1)<=COUNTIF(A:A,B1),"Exists","Missing")
F2: =IF(COUNTIF($B$1:$B2,B2)<=COUNTIF(A:A,B2),"Exists","Missing")
and so on
Explanation:
In column C we count how many times the value of the respective cell
of Column B exist in the whole Column A.
In Column D we count how many times we have "met" this value in Column B so far.
In Column E we check if we have "met" the value more times that it exists in Column A. If indeed we have "met" it more times, then we mark the cell as "missing"
Tested with the example you provided and works okay.
I hope it helps!
Good luck!
EDIT - Addition of Screenshot
I have a two table in Excel. I want to search for the code in column B in the first table. I want to write row and column names in column C when I find this value in the array in the second table.
Excel screenshot - More details are included in the screenshot.
Thank you!
In cell C2 and copied down:
=IF(COUNTIF($F$2:$I$3,B2)=0,"",INDEX($1:$1,,SUMPRODUCT(($F$2:$I$3=B2)*COLUMN($F$2:$I$3)))&"-"&INDEX($E:$E,SUMPRODUCT(($F$2:$I$3=B2)*ROW($F$2:$I$3))))
I recommend splitting Column C into two columns. For the formula that I wrote, I put Room in Column C and Table in Column D.
This formula goes into cell B2:
“=index($F$2:$I$3,match($D2,$E$2:$E$3,0),match($C2,$F$1:$I$1,0))”
I'm setting up an excel file for the operators. They will scan the Barcode from the product and it will populate in one of the column of the excel sheet.
I have tried using LOOKUP formula in excel but it doesn't seem to be working right.
COL A : Data from Database
COL B : Data from Scanner
COL C: Row number
Find the value of Column B in Col A and populate the Row no. in Column C.
=LOOKUP(B5,A:A,ROW(A:A))
I have used this formula in every cell of the column C.
The row number don't populate accurately.
=MATCH(B5,A:A,0) should give you the rownumber. And if you wish to obtain the cell's address: =ADDRESS(MATCH(B5,A:A,0),1,4,1)
If you are using combined cells then you definiately want to use absolute ranges like =MATCH(B5,$A$5:$A$10,0)
Search B column in A column and get row back. You could use:
Note:
Do not forget to use IFNA in case of B does not included in A.
In my opinion there is no need to target whole range.
=IFNA(MATCH(B1,$A$1:$A$6,0)+ROW($A$1:$A$6)-1,"")
Results:
Would really appreciate some help. Pretty basic problem. In column A I have SSN's, Column B I also have SSN's and in column C I have dates associated with the SSN's in Column B. The problem the 2 different SSN's columns don't match and I need them too. Problem 2: The dates in column C need to stay associated with the same socials in column b.
This is fairly simple.
Either in a new sheet or in separate columns from your original data, create create a column that represents the same column as A or the original SSN's, this can easily be done with a simple reference formula =A1 and autofilled down. You can do the same for the second column that is a copy of the first SSN.
For the third column just use a simple INDEXand MATCHformula like this:
=INDEX(C:C,MATCH(E1,B:B,0))
This formula I have the new data in Columns E-G with this formula in column G.
What this formula is doing is looking for the value of E1 within column B (looking for the value of the first SSN within the span of the column B). It will then grab the date value from column C associated with the found value in B. This will not work if multiple of the same SSN's are found within column B.
Note: You have to set the formatting of the formula cell as a Date
I have a spreadsheet which has 3 columns
Col A is a unique reference number
Col B is the surname
Col C is the firstname
In another worksheet I want to be able to type in a surname in cell A2, a firstname in cell A3 and have cell A1 automatically populated with the unique reference number.
Is this possible in Excel and if so could you give me an example of how to do it?
Thanks,
Greg
VLOOKUP requires that the data that you're looking up is in the first column and that the range is sorted by that column.
If that's not an issue, then you could shift your columns on your source sheet to the right and put in a new column containing something like =CONCATENATE(upper(C1)," ",upper(D1)) into the new column A - then use VLOOKUP against that column. (this is what Kaloyan said).
Otherwise you could put your concatenated, capitalised column and index on another (hidden) sheet and run your vlookup against that range.
Most straightforward way would be to combine the two names in another column like so: =upper(B1)&" "&upper(C1). Then you can do a vlookup on those values to get the unique ref #.